net/ipv6/ip6mr.c
Source file repositories/reference/linux-study-clean/net/ipv6/ip6mr.c
File Facts
- System
- Linux kernel
- Corpus path
net/ipv6/ip6mr.c- Extension
.c- Size
- 68899 bytes
- Lines
- 2832
- Domain
- Networking Core
- Bucket
- Sockets, Protocols, Packet Path, And Network Policy
- Inferred role
- Networking Core: operation-table or driver-model contract
- Status
- pattern 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.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/uaccess.hlinux/types.hlinux/sched.hlinux/errno.hlinux/mm.hlinux/kernel.hlinux/fcntl.hlinux/stat.hlinux/socket.hlinux/inet.hlinux/netdevice.hlinux/inetdevice.hlinux/proc_fs.hlinux/seq_file.hlinux/init.hlinux/compat.hlinux/rhashtable.hnet/protocol.hlinux/skbuff.hnet/raw.hlinux/notifier.hlinux/if_arp.hnet/checksum.hnet/netlink.hnet/fib_rules.hnet/ipv6.hnet/ip6_route.hlinux/mroute6.hlinux/pim.hnet/addrconf.hlinux/netfilter_ipv6.hlinux/export.h
Detected Declarations
struct ip6mr_rulestruct ip6mr_resultstruct compat_sioc_sg_req6struct compat_sioc_mif_req6function lockdep_rtnl_is_heldfunction ip6mr_for_each_tablefunction ip6mr_fib_lookupfunction ip6mr_rule_actionfunction ip6mr_rule_matchfunction ip6mr_rule_configurefunction ip6mr_rule_comparefunction ip6mr_rule_fillfunction ip6mr_rules_initfunction ip6mr_rules_exitfunction ip6mr_rules_exit_rtnlfunction list_for_each_entry_safefunction ip6mr_rules_dumpfunction ip6mr_rules_seq_readfunction ip6mr_rule_defaultfunction ip6mr_fib_lookupfunction ip6mr_rules_initfunction ip6mr_rules_exitfunction ip6mr_rules_dumpfunction ip6mr_rules_seq_readfunction ip6mr_hash_cmpfunction ip6mr_new_table_setfunction ip6mr_free_tablefunction ip6mr_vif_seq_stopfunction ip6mr_vif_seq_showfunction ipmr_mfc_seq_showfunction pim6_rcvfunction reg_vif_xmitfunction reg_vif_get_iflinkfunction reg_vif_setupfunction call_ip6mr_vif_entry_notifiersfunction call_ip6mr_mfc_entry_notifiersfunction mif6_deletefunction ip6mr_cache_free_rcufunction ip6mr_cache_freefunction ip6mr_destroy_unresfunction ipmr_do_expire_processfunction list_for_each_entry_safefunction ipmr_expire_processfunction ip6mr_update_thresholdsfunction mif6_addfunction ip6mr_cache_find_parentfunction ip6mr_cache_resolvefunction rcu_read_lock
Annotated Snippet
static const struct net_device_ops reg_vif_netdev_ops = {
.ndo_start_xmit = reg_vif_xmit,
.ndo_get_iflink = reg_vif_get_iflink,
};
static void reg_vif_setup(struct net_device *dev)
{
dev->type = ARPHRD_PIMREG;
dev->mtu = 1500 - sizeof(struct ipv6hdr) - 8;
dev->flags = IFF_NOARP;
dev->netdev_ops = ®_vif_netdev_ops;
dev->needs_free_netdev = true;
dev->netns_immutable = true;
}
static struct net_device *ip6mr_reg_vif(struct net *net, struct mr_table *mrt)
{
struct net_device *dev;
char name[IFNAMSIZ];
if (mrt->id == RT6_TABLE_DFLT)
sprintf(name, "pim6reg");
else
sprintf(name, "pim6reg%u", mrt->id);
dev = alloc_netdev(0, name, NET_NAME_UNKNOWN, reg_vif_setup);
if (!dev)
return NULL;
dev_net_set(dev, net);
if (register_netdevice(dev)) {
free_netdev(dev);
return NULL;
}
if (dev_open(dev, NULL))
goto failure;
dev_hold(dev);
return dev;
failure:
unregister_netdevice(dev);
return NULL;
}
#endif
static int call_ip6mr_vif_entry_notifiers(struct net *net,
enum fib_event_type event_type,
struct vif_device *vif,
struct net_device *vif_dev,
mifi_t vif_index, u32 tb_id)
{
return mr_call_vif_notifiers(net, RTNL_FAMILY_IP6MR, event_type,
vif, vif_dev, vif_index, tb_id,
&net->ipv6.ipmr_seq);
}
static int call_ip6mr_mfc_entry_notifiers(struct net *net,
enum fib_event_type event_type,
struct mfc6_cache *mfc, u32 tb_id)
{
return mr_call_mfc_notifiers(net, RTNL_FAMILY_IP6MR, event_type,
&mfc->_c, tb_id, &net->ipv6.ipmr_seq);
}
/* Delete a VIF entry */
static int mif6_delete(struct mr_table *mrt, int vifi, int notify,
struct list_head *head)
{
struct vif_device *v;
struct net_device *dev;
struct inet6_dev *in6_dev;
if (vifi < 0 || vifi >= mrt->maxvif)
return -EADDRNOTAVAIL;
v = &mrt->vif_table[vifi];
dev = rtnl_dereference(v->dev);
if (!dev)
return -EADDRNOTAVAIL;
call_ip6mr_vif_entry_notifiers(read_pnet(&mrt->net),
FIB_EVENT_VIF_DEL, v, dev,
vifi, mrt->id);
spin_lock(&mrt_lock);
RCU_INIT_POINTER(v->dev, NULL);
Annotation
- Immediate include surface: `linux/uaccess.h`, `linux/types.h`, `linux/sched.h`, `linux/errno.h`, `linux/mm.h`, `linux/kernel.h`, `linux/fcntl.h`, `linux/stat.h`.
- Detected declarations: `struct ip6mr_rule`, `struct ip6mr_result`, `struct compat_sioc_sg_req6`, `struct compat_sioc_mif_req6`, `function lockdep_rtnl_is_held`, `function ip6mr_for_each_table`, `function ip6mr_fib_lookup`, `function ip6mr_rule_action`, `function ip6mr_rule_match`, `function ip6mr_rule_configure`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: pattern implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.