net/openvswitch/flow.c
Source file repositories/reference/linux-study-clean/net/openvswitch/flow.c
File Facts
- System
- Linux kernel
- Corpus path
net/openvswitch/flow.c- Extension
.c- Size
- 28916 bytes
- Lines
- 1117
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/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/cpumask.hlinux/if_arp.hlinux/ip.hlinux/ipv6.hlinux/mpls.hlinux/sctp.hlinux/smp.hlinux/tcp.hlinux/udp.hlinux/icmp.hlinux/icmpv6.hlinux/rculist.hnet/ip.hnet/ip_tunnels.hnet/ipv6.hnet/mpls.hnet/ndisc.hnet/nsh.hnet/pkt_cls.h
Detected Declarations
struct llc_snap_hdrfunction Copyrightfunction ovs_flow_stats_updatefunction ovs_flow_stats_getfunction for_each_cpufunction ovs_flow_stats_clearfunction for_each_cpufunction check_headerfunction arphdr_okfunction check_iphdrfunction tcphdr_okfunction udphdr_okfunction sctphdr_okfunction icmphdr_okfunction get_ipv6_ext_hdrsfunction parse_ipv6hdrfunction icmp6hdr_okfunction parse_vlan_tagfunction clear_vlanfunction parse_vlanfunction parse_ethertypefunction parse_icmpv6function parse_nshfunction key_extract_l3l4function key_extractfunction ovs_flow_key_update_l3l4function ovs_flow_key_updatefunction key_extract_mac_protofunction ovs_flow_key_extractfunction ovs_flow_key_extract_userspace
Annotated Snippet
struct llc_snap_hdr {
u8 dsap; /* Always 0xAA */
u8 ssap; /* Always 0xAA */
u8 ctrl;
u8 oui[3];
__be16 ethertype;
};
struct llc_snap_hdr *llc;
__be16 proto;
proto = *(__be16 *) skb->data;
__skb_pull(skb, sizeof(__be16));
if (eth_proto_is_802_3(proto))
return proto;
if (skb->len < sizeof(struct llc_snap_hdr))
return htons(ETH_P_802_2);
if (unlikely(!pskb_may_pull(skb, sizeof(struct llc_snap_hdr))))
return htons(0);
llc = (struct llc_snap_hdr *) skb->data;
if (llc->dsap != LLC_SAP_SNAP ||
llc->ssap != LLC_SAP_SNAP ||
(llc->oui[0] | llc->oui[1] | llc->oui[2]) != 0)
return htons(ETH_P_802_2);
__skb_pull(skb, sizeof(struct llc_snap_hdr));
if (eth_proto_is_802_3(llc->ethertype))
return llc->ethertype;
return htons(ETH_P_802_2);
}
static int parse_icmpv6(struct sk_buff *skb, struct sw_flow_key *key,
int nh_len)
{
struct icmp6hdr *icmp = icmp6_hdr(skb);
/* The ICMPv6 type and code fields use the 16-bit transport port
* fields, so we need to store them in 16-bit network byte order.
*/
key->tp.src = htons(icmp->icmp6_type);
key->tp.dst = htons(icmp->icmp6_code);
if (icmp->icmp6_code == 0 &&
(icmp->icmp6_type == NDISC_NEIGHBOUR_SOLICITATION ||
icmp->icmp6_type == NDISC_NEIGHBOUR_ADVERTISEMENT)) {
int icmp_len = skb->len - skb_transport_offset(skb);
struct nd_msg *nd;
int offset;
memset(&key->ipv6.nd, 0, sizeof(key->ipv6.nd));
/* In order to process neighbor discovery options, we need the
* entire packet.
*/
if (unlikely(icmp_len < sizeof(*nd)))
return 0;
if (unlikely(skb_linearize(skb)))
return -ENOMEM;
nd = (struct nd_msg *)skb_transport_header(skb);
key->ipv6.nd.target = nd->target;
icmp_len -= sizeof(*nd);
offset = 0;
while (icmp_len >= 8) {
struct nd_opt_hdr *nd_opt =
(struct nd_opt_hdr *)(nd->opt + offset);
int opt_len = nd_opt->nd_opt_len * 8;
if (unlikely(!opt_len || opt_len > icmp_len))
return 0;
/* Store the link layer address if the appropriate
* option is provided. It is considered an error if
* the same link layer option is specified twice.
*/
if (nd_opt->nd_opt_type == ND_OPT_SOURCE_LL_ADDR
&& opt_len == 8) {
if (unlikely(!is_zero_ether_addr(key->ipv6.nd.sll)))
goto invalid;
ether_addr_copy(key->ipv6.nd.sll,
&nd->opt[offset+sizeof(*nd_opt)]);
} else if (nd_opt->nd_opt_type == ND_OPT_TARGET_LL_ADDR
&& opt_len == 8) {
Annotation
- Immediate include surface: `linux/uaccess.h`, `linux/netdevice.h`, `linux/etherdevice.h`, `linux/if_ether.h`, `linux/if_vlan.h`, `net/llc_pdu.h`, `linux/kernel.h`, `linux/jhash.h`.
- Detected declarations: `struct llc_snap_hdr`, `function Copyright`, `function ovs_flow_stats_update`, `function ovs_flow_stats_get`, `function for_each_cpu`, `function ovs_flow_stats_clear`, `function for_each_cpu`, `function check_header`, `function arphdr_ok`, `function check_iphdr`.
- 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.