Linux协议栈网桥部分之主要数据结构

Linux网桥主要数据结构


struct net_bridge_fdb_entry
{
struct hlist_node hlist; //用于CAM表连接的链表指针
struct net_bridge_port *dst; //对应的物理接口指针,其中包含一个net_device的指针指向该物理网口
struct rcu_head rcu; //RCU锁
atomic_t use_count; //当前引用计数
unsigned long ageing_timer; //超时时间
mac_addr addr; //MAC地址
unsigned char is_local; //标明是否为本机MAC地址
unsigned char is_static; //标明是否为静态地址
};

struct net_bridge
{
spinlock_t lock; //自旋锁
struct list_head port_list; //桥组中的端口列表
struct net_device *dev; //网桥会建立一个虚拟设备来进行管理,这个设备的MAC地址是动态指定的,通常就是桥组中一个物理端口的MAC地址
struct net_device_stats statistics; //网桥中虚拟网卡的统计数据
spinlock_t hash_lock; //hash列表自旋锁
struct hlist_head hash[BR_HASH_SIZE]; //存放的是net_bridge_fdb_entry的哈希表,实际上就是mac和port的对应表
struct list_head age_list;
unsigned long feature_mask;

/*以下定义了STP协议所使用的信息*/
bridge_id designated_root; //DR
bridge_id bridge_id; //这个成员一下是stp相关的信息
u32 root_path_cost;
unsigned long max_age;
unsigned long hello_time;
unsigned long forward_delay;
unsigned long bridge_max_age;
unsigned long ageing_time;
unsigned long bridge_hello_time;
unsigned long bridge_forward_delay;

u8 group_addr[ETH_ALEN];
u16 root_port;

enum {
BR_NO_STP, /* no spanning tree */
BR_KERNEL_STP, /* old STP in kernel */
BR_USER_STP, /* new RSTP in userspace */
} stp_enabled;

unsigned char topology_change;
unsigned char topology_change_detected;

struct timer_list hello_timer;
struct timer_list tcn_timer;
struct timer_list topology_change_timer;
struct timer_list gc_timer;
struct kobject ifobj;
};

//网桥中的端口,它实际上表示的是接收该数据包的网桥的端口的相关信息
struct net_bridge_port
{
struct net_bridge *br; //当前端口所在的briage
struct net_device *dev; //此端口对应的物理端口
struct list_head list; //同一桥内的端口链表

/* 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;

struct timer_list forward_delay_timer;
struct timer_list hold_timer;
struct timer_list message_age_timer;
struct kobject kobj;
struct rcu_head rcu;
};



posted @ 2012-01-12 20:59  yarpee  阅读(364)  评论(0编辑  收藏  举报