/net/bridge/br_arp_nd_proxy.c
br_arp_nd_proxy.c
包括网桥上的ARP协议与IP6的邻居发现协议相关操作。
net_bridge
见br.c
解析
net_bridge_port
网桥端口数据结构,代表某一个端口。
struct net_bridge_port {
struct net_bridge *br;
struct net_device *dev;
struct list_head list;
unsigned long flags;
#ifdef CONFIG_BRIDGE_VLAN_FILTERING
struct net_bridge_vlan_group __rcu *vlgrp;
#endif
struct net_bridge_port __rcu *backup_port;
/* STP */
u8 priority;
u8 state;
u16 port_no;
unsigned char topology_change_ack;
unsigned char config_pending;
port_id port_id;
port_id designated_port;
bridge_id designated_root;
bridge_id designated_bridge;
u32 path_cost;
u32 designated_cost;
unsigned long designated_age;
struct timer_list forward_delay_timer;
struct timer_list hold_timer;
struct timer_list message_age_timer;
struct kobject kobj;
struct rcu_head rcu;
#ifdef CONFIG_BRIDGE_IGMP_SNOOPING
struct bridge_mcast_own_query ip4_own_query;
struct timer_list ip4_mc_router_timer;
struct hlist_node ip4_rlist;
#if IS_ENABLED(CONFIG_IPV6)
struct bridge_mcast_own_query ip6_own_query;
struct timer_list ip6_mc_router_timer;
struct hlist_node ip6_rlist;
#endif /* IS_ENABLED(CONFIG_IPV6) */
u32 multicast_eht_hosts_limit;
u32 multicast_eht_hosts_cnt;
unsigned char multicast_router;
struct bridge_mcast_stats __percpu *mcast_stats;
struct hlist_head mglist;
#endif
#ifdef CONFIG_SYSFS
char sysfs_name[IFNAMSIZ];
#endif
#ifdef CONFIG_NET_POLL_CONTROLLER
struct netpoll *np;
#endif
#ifdef CONFIG_NET_SWITCHDEV
int offload_fwd_mark;
#endif
u16 group_fwd_mask;
u16 backup_redirected_cnt;
struct bridge_stp_xstats stp_xstats;
};
sk_buff
sk_buff
的定义在/include/linux/skbuff.h
里,内容发非常多。
简单的说,一个skb_buff
变量就代表了一个数据报,可以在系统中流转。完整地包含了一个数据报所需的全部内容和相关信息与属性。
br_recalculate_neigh_suppress_enabled
:设置是否允许进行流控。
void br_recalculate_neigh_suppress_enabled(struct net_bridge *br)
br_arp_send
:通过src_ip
和dest_ip
数据发送ARP报文。
static void br_arp_send(struct net_bridge *br, struct net_bridge_port *p,
struct net_device *dev, __be32 dest_ip, __be32 src_ip,
const unsigned char *dest_hw,
const unsigned char *src_hw,
const unsigned char *target_hw,
__be16 vlan_proto, u16 vlan_tci)
br_chk_addr_ip
:判断指定设备于IP是否相符。
static int br_chk_addr_ip(struct net_device *dev, struct netdev_nested_priv *priv)
br_is_local_ip
:检查IP是否是该设备或上层设备的IP。
static bool br_is_local_ip(struct net_device *dev, __be32 ip)
br_do_proxy_suppress_arp
:向支持BR_NEIGH_SUPPRESS
或BR_PROXYARP_WIFI
的端口发送ARP报文。
void br_do_proxy_suppress_arp(struct sk_buff *skb, struct net_bridge *br,
u16 vid, struct net_bridge_port *p)
br_is_nd_neigh_msg
:打开CONFIG_IPV6
才有效。判断是否是IP6的邻居发现协议。
struct nd_msg *br_is_nd_neigh_msg(struct sk_buff *skb, struct nd_msg *msg)
br_nd_send
:发送IP6的邻居发现协议报文。
static void br_nd_send(struct net_bridge *br, struct net_bridge_port *p,
struct sk_buff *request, struct neighbour *n,
__be16 vlan_proto, u16 vlan_tci, struct nd_msg *ns)
br_chk_addr_ip6
:检查设备与IP6的地址是否相符。
static int br_chk_addr_ip6(struct net_device *dev, struct netdev_nested_priv *priv)
br_is_local_ip6
:检查IP6地址是否是本设备地址或上层设备地址。
static bool br_is_local_ip6(struct net_device *dev, struct in6_addr *addr)
br_do_suppress_nd
:发送IP6的流控帧。
void br_do_suppress_nd(struct sk_buff *skb, struct net_bridge *br,
u16 vid, struct net_bridge_port *p, struct nd_msg *msg)