net/bridge/br_cfm_netlink.c

Source file repositories/reference/linux-study-clean/net/bridge/br_cfm_netlink.c

File Facts

System
Linux kernel
Corpus path
net/bridge/br_cfm_netlink.c
Extension
.c
Size
21293 bytes
Lines
729
Domain
Networking Core
Bucket
Sockets, Protocols, Packet Path, And Network Policy
Inferred role
Networking Core: implementation source
Status
source implementation candidate

Why This File Exists

Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.

Dependency Surface

Detected Declarations

Annotated Snippet

hlist_for_each_entry_rcu(peer_mep, &mep->peer_mep_list, head) {
			tb = nla_nest_start(skb,
					    IFLA_BRIDGE_CFM_CC_PEER_MEP_INFO);

			if (!tb)
				goto nla_info_failure;

			if (nla_put_u32(skb,
					IFLA_BRIDGE_CFM_CC_PEER_MEP_INSTANCE,
					mep->instance))
				goto nla_put_failure;

			if (nla_put_u32(skb, IFLA_BRIDGE_CFM_CC_PEER_MEPID,
					peer_mep->mepid))
				goto nla_put_failure;

			nla_nest_end(skb, tb);
		}
	}

	return 0;

nla_put_failure:
	nla_nest_cancel(skb, tb);

nla_info_failure:
	return -EMSGSIZE;
}

int br_cfm_status_fill_info(struct sk_buff *skb,
			    struct net_bridge *br,
			    bool getlink)
{
	struct br_cfm_peer_mep *peer_mep;
	struct br_cfm_mep *mep;
	struct nlattr *tb;

	hlist_for_each_entry_rcu(mep, &br->mep_list, head) {
		tb = nla_nest_start(skb, IFLA_BRIDGE_CFM_MEP_STATUS_INFO);
		if (!tb)
			goto nla_info_failure;

		if (nla_put_u32(skb, IFLA_BRIDGE_CFM_MEP_STATUS_INSTANCE,
				mep->instance))
			goto nla_put_failure;

		if (nla_put_u32(skb,
				IFLA_BRIDGE_CFM_MEP_STATUS_OPCODE_UNEXP_SEEN,
				mep->status.opcode_unexp_seen))
			goto nla_put_failure;

		if (nla_put_u32(skb,
				IFLA_BRIDGE_CFM_MEP_STATUS_VERSION_UNEXP_SEEN,
				mep->status.version_unexp_seen))
			goto nla_put_failure;

		if (nla_put_u32(skb,
				IFLA_BRIDGE_CFM_MEP_STATUS_RX_LEVEL_LOW_SEEN,
				mep->status.rx_level_low_seen))
			goto nla_put_failure;

		/* Only clear if this is a GETLINK */
		if (getlink) {
			/* Clear all 'seen' indications */
			mep->status.opcode_unexp_seen = false;
			mep->status.version_unexp_seen = false;
			mep->status.rx_level_low_seen = false;
		}

		nla_nest_end(skb, tb);

		hlist_for_each_entry_rcu(peer_mep, &mep->peer_mep_list, head) {
			tb = nla_nest_start(skb,
					    IFLA_BRIDGE_CFM_CC_PEER_STATUS_INFO);
			if (!tb)
				goto nla_info_failure;

			if (nla_put_u32(skb,
					IFLA_BRIDGE_CFM_CC_PEER_STATUS_INSTANCE,
					mep->instance))
				goto nla_put_failure;

			if (nla_put_u32(skb,
					IFLA_BRIDGE_CFM_CC_PEER_STATUS_PEER_MEPID,
					peer_mep->mepid))
				goto nla_put_failure;

			if (nla_put_u32(skb,
					IFLA_BRIDGE_CFM_CC_PEER_STATUS_CCM_DEFECT,
					peer_mep->cc_status.ccm_defect))

Annotation

Implementation Notes