net/openvswitch/flow_netlink.c
Source file repositories/reference/linux-study-clean/net/openvswitch/flow_netlink.c
File Facts
- System
- Linux kernel
- Corpus path
net/openvswitch/flow_netlink.c- Extension
.c- Size
- 102909 bytes
- Lines
- 3804
- 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.
- Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
flow.hdatapath.hlinux/uaccess.hlinux/netdevice.hlinux/etherdevice.hlinux/if_ether.hlinux/if_vlan.hnet/llc_pdu.hlinux/kernel.hlinux/jhash.hlinux/jiffies.hlinux/llc.hlinux/module.hlinux/in.hlinux/rcupdate.hlinux/if_arp.hlinux/ip.hlinux/ipv6.hlinux/sctp.hlinux/tcp.hlinux/udp.hlinux/icmp.hlinux/icmpv6.hlinux/rculist.hnet/geneve.hnet/ip.hnet/ipv6.hnet/ndisc.hnet/mpls.hnet/vxlan.hnet/tun_proto.hnet/erspan.h
Detected Declarations
struct ovs_len_tblfunction actions_may_change_flowfunction nla_for_each_nestedfunction update_rangefunction match_validatefunction ovs_tun_key_attr_sizefunction ovs_nsh_key_attr_sizefunction ovs_key_attr_sizefunction check_attr_lenfunction is_all_zerofunction __parse_flow_nlattrsfunction parse_flow_mask_nlattrsfunction parse_flow_nlattrsfunction genev_tun_opt_from_nlattrfunction attributesfunction vxlan_tun_opt_from_nlattrfunction erspan_tun_opt_from_nlattrfunction ip_tun_from_nlattrfunction nla_for_each_nestedfunction vxlan_opt_to_nlattrfunction __ip_tun_to_nlattrfunction ip_tun_to_nlattrfunction ovs_nla_put_tunnel_infofunction encode_vlan_from_nlattrsfunction validate_vlan_from_nlattrsfunction validate_vlan_mask_from_nlattrsfunction __parse_vlan_from_nlattrsfunction parse_vlan_from_nlattrsfunction parse_eth_type_from_nlattrsfunction metadata_from_nlattrsfunction ovs_ct_verifyfunction ovs_ct_verifyfunction ovs_ct_verifyfunction validate_push_nshfunction nla_for_each_nestedfunction nsh_key_put_from_nlattrfunction nla_for_each_nestedfunction ovs_key_from_nlattrsfunction nlattr_setfunction mask_set_nlattrfunction ovs_nla_get_matchfunction get_ufid_lenfunction ovs_nla_get_ufidfunction ovs_nla_get_identifierfunction ovs_nla_get_ufid_flagsfunction flow_from_nlattrsfunction ovs_nla_put_vlanfunction nsh_key_to_nlattr
Annotated Snippet
struct ovs_len_tbl {
int len;
const struct ovs_len_tbl *next;
};
#define OVS_ATTR_NESTED -1
#define OVS_ATTR_VARIABLE -2
#define OVS_COPY_ACTIONS_MAX_DEPTH 16
static bool actions_may_change_flow(const struct nlattr *actions)
{
struct nlattr *nla;
int rem;
nla_for_each_nested(nla, actions, rem) {
u16 action = nla_type(nla);
switch (action) {
case OVS_ACTION_ATTR_OUTPUT:
case OVS_ACTION_ATTR_RECIRC:
case OVS_ACTION_ATTR_TRUNC:
case OVS_ACTION_ATTR_USERSPACE:
case OVS_ACTION_ATTR_DROP:
case OVS_ACTION_ATTR_PSAMPLE:
break;
case OVS_ACTION_ATTR_CT:
case OVS_ACTION_ATTR_CT_CLEAR:
case OVS_ACTION_ATTR_HASH:
case OVS_ACTION_ATTR_POP_ETH:
case OVS_ACTION_ATTR_POP_MPLS:
case OVS_ACTION_ATTR_POP_NSH:
case OVS_ACTION_ATTR_POP_VLAN:
case OVS_ACTION_ATTR_PUSH_ETH:
case OVS_ACTION_ATTR_PUSH_MPLS:
case OVS_ACTION_ATTR_PUSH_NSH:
case OVS_ACTION_ATTR_PUSH_VLAN:
case OVS_ACTION_ATTR_SAMPLE:
case OVS_ACTION_ATTR_SET:
case OVS_ACTION_ATTR_SET_MASKED:
case OVS_ACTION_ATTR_METER:
case OVS_ACTION_ATTR_CHECK_PKT_LEN:
case OVS_ACTION_ATTR_ADD_MPLS:
case OVS_ACTION_ATTR_DEC_TTL:
default:
return true;
}
}
return false;
}
static void update_range(struct sw_flow_match *match,
size_t offset, size_t size, bool is_mask)
{
struct sw_flow_key_range *range;
size_t start = rounddown(offset, sizeof(long));
size_t end = roundup(offset + size, sizeof(long));
if (!is_mask)
range = &match->range;
else
range = &match->mask->range;
if (range->start == range->end) {
range->start = start;
range->end = end;
return;
}
if (range->start > start)
range->start = start;
if (range->end < end)
range->end = end;
}
#define SW_FLOW_KEY_PUT(match, field, value, is_mask) \
do { \
update_range(match, offsetof(struct sw_flow_key, field), \
sizeof((match)->key->field), is_mask); \
if (is_mask) \
(match)->mask->key.field = value; \
else \
(match)->key->field = value; \
} while (0)
#define SW_FLOW_KEY_MEMCPY_OFFSET(match, offset, value_p, len, is_mask) \
do { \
update_range(match, offset, len, is_mask); \
if (is_mask) \
Annotation
- Immediate include surface: `flow.h`, `datapath.h`, `linux/uaccess.h`, `linux/netdevice.h`, `linux/etherdevice.h`, `linux/if_ether.h`, `linux/if_vlan.h`, `net/llc_pdu.h`.
- Detected declarations: `struct ovs_len_tbl`, `function actions_may_change_flow`, `function nla_for_each_nested`, `function update_range`, `function match_validate`, `function ovs_tun_key_attr_size`, `function ovs_nsh_key_attr_size`, `function ovs_key_attr_size`, `function check_attr_len`, `function is_all_zero`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.