0326
0327
0328
0329
0330
0331
0332
0333
0334
0335
0336
0337
0338
0339
0340
0341
0342
0343
0344
0345
0346
0347
0348
0349
0350
0351
0352
0353
0354
0355
0356
0357
0358
0359
0360
0361
0362
0363
0364
0365
0366
0367
0368
0369
0370
0371
0372
0373
0374
0375
0376
0377
0378
0379
0380
0381
0382
0383
0384
0385
0386
0387
0388 struct sk_buff {
0389
0390 struct sk_buff *next;
0391 struct sk_buff *prev;
0392
0393 ktime_t tstamp;
0394
0395 struct sock *sk;
0396 struct net_device *dev;
0397
0398
0399
0400
0401
0402
0403
0404 char cb[48] __aligned(8);
0405
0406 unsigned long _skb_refdst;
0407 #ifdef CONFIG_XFRM
0408 struct sec_path *sp;
0409 #endif
0410 unsigned int len,
0411 data_len;
0412 __u16 mac_len,
0413 hdr_len;
0414 union {
0415 __wsum csum;
0416 struct {
0417 __u16 csum_start;
0418 __u16 csum_offset;
0419 };
0420 };
0421 __u32 priority;
0422 kmemcheck_bitfield_begin(flags1);
0423 __u8 local_df:1,
0424 cloned:1,
0425 ip_summed:2,
0426 nohdr:1,
0427 nfctinfo:3;
0428 __u8 pkt_type:3,
0429 fclone:2,
0430 ipvs_property:1,
0431 peeked:1,
0432 nf_trace:1;
0433 kmemcheck_bitfield_end(flags1);
0434 __be16 protocol;
0435
0436 void (*destructor)(struct sk_buff *skb);
0437 #if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
0438 struct nf_conntrack *nfct;
0439 #endif
0440 #ifdef NET_SKBUFF_NF_DEFRAG_NEEDED
0441 struct sk_buff *nfct_reasm;
0442 #endif
0443 #ifdef CONFIG_BRIDGE_NETFILTER
0444 struct nf_bridge_info *nf_bridge;
0445 #endif
0446
0447 int skb_iif;
0448
0449 __u32 rxhash;
0450
0451 __u16 vlan_tci;
0452
0453 #ifdef CONFIG_NET_SCHED
0454 __u16 tc_index;
0455 #ifdef CONFIG_NET_CLS_ACT
0456 __u16 tc_verd;
0457 #endif
0458 #endif
0459
0460 __u16 queue_mapping;
0461 kmemcheck_bitfield_begin(flags2);
0462 #ifdef CONFIG_IPV6_NDISC_NODETYPE
0463 __u8 ndisc_nodetype:2;
0464 #endif
0465 __u8 ooo_okay:1;
0466 __u8 l4_rxhash:1;
0467 __u8 wifi_acked_valid:1;
0468 __u8 wifi_acked:1;
0469 __u8 no_fcs:1;
0470 __u8 head_frag:1;
0471
0472 kmemcheck_bitfield_end(flags2);
0473
0474 #ifdef CONFIG_NET_DMA
0475 dma_cookie_t dma_cookie;
0476 #endif
0477 #ifdef CONFIG_NETWORK_SECMARK
0478 __u32 secmark;
0479 #endif
0480 union {
0481 __u32 mark;
0482 __u32 dropcount;
0483 __u32 avail_size;
0484 };
0485
0486 sk_buff_data_t transport_header;
0487 sk_buff_data_t network_header;
0488 sk_buff_data_t mac_header;
0489
0490 sk_buff_data_t tail;
0491 sk_buff_data_t end;
0492 unsigned char *head,
0493 *data;
0494 unsigned int truesize;
0495 atomic_t users;
0496 };
1040 struct net_device {
1041
1042
1043
1044
1045
1046
1047 char name[IFNAMSIZ];
1048
1049 struct pm_qos_request pm_qos_req;
1050
1051
1052 struct hlist_node name_hlist;
1053
1054 char *ifalias;
1055
1056
1057
1058
1059
1060 unsigned long mem_end;
1061 unsigned long mem_start;
1062 unsigned long base_addr;
1063 unsigned int irq;
1064
1065
1066
1067
1068
1069
1070 unsigned long state;
1071
1072 struct list_head dev_list;
1073 struct list_head napi_list;
1074 struct list_head unreg_list;
1075
1076
1077 netdev_features_t features;
1078
1079 netdev_features_t hw_features;
1080
1081 netdev_features_t wanted_features;
1082
1083 netdev_features_t vlan_features;
1084
1085
1086 int ifindex;
1087 int iflink;
1088
1089 struct net_device_stats stats;
1090 atomic_long_t rx_dropped;
1091
1092
1093
1094 #ifdef CONFIG_WIRELESS_EXT
1095
1096
1097 const struct iw_handler_def * wireless_handlers;
1098
1099 struct iw_public_data * wireless_data;
1100 #endif
1101
1102 const struct net_device_ops *netdev_ops;
1103 const struct ethtool_ops *ethtool_ops;
1104
1105
1106 const struct header_ops *header_ops;
1107
1108 unsigned int flags;
1109 unsigned int priv_flags;
1110
1111 unsigned short gflags;
1112 unsigned short padded;
1113
1114 unsigned char operstate;
1115 unsigned char link_mode;
1116
1117 unsigned char if_port;
1118 unsigned char dma;
1119
1120 unsigned int mtu;
1121 unsigned short type;
1122 unsigned short hard_header_len;
1123
1124
1125
1126
1127
1128 unsigned short needed_headroom;
1129 unsigned short needed_tailroom;
1130
1131
1132 unsigned char perm_addr[MAX_ADDR_LEN];
1133 unsigned char addr_assign_type;
1134 unsigned char addr_len;
1135 unsigned char neigh_priv_len;
1136 unsigned short dev_id;
1137
1138 spinlock_t addr_list_lock;
1139 struct netdev_hw_addr_list uc;
1140 struct netdev_hw_addr_list mc;
1141 bool uc_promisc;
1142 unsigned int promiscuity;
1143 unsigned int allmulti;
1144
1145
1146
1147
1148 #if IS_ENABLED(CONFIG_VLAN_8021Q)
1149 struct vlan_info __rcu *vlan_info;
1150 #endif
1151 #if IS_ENABLED(CONFIG_NET_DSA)
1152 struct dsa_switch_tree *dsa_ptr;
1153 #endif
1154 void *atalk_ptr;
1155 struct in_device __rcu *ip_ptr;
1156 struct dn_dev __rcu *dn_ptr;
1157 struct inet6_dev __rcu *ip6_ptr;
1158 void *ax25_ptr;
1159 struct wireless_dev *ieee80211_ptr;
1160
1161
1162
1163
1164
1165 unsigned long last_rx;
1166
1167
1168
1169
1170
1171
1172
1173 struct net_device *master;
1174
1175
1176
1177
1178 unsigned char *dev_addr;
1179
1180
1181
1182 struct netdev_hw_addr_list dev_addrs;
1183
1184
1185 unsigned char broadcast[MAX_ADDR_LEN];
1186
1187 #ifdef CONFIG_SYSFS
1188 struct kset *queues_kset;
1189 #endif
1190
1191 #ifdef CONFIG_RPS
1192 struct netdev_rx_queue *_rx;
1193
1194
1195 unsigned int num_rx_queues;
1196
1197
1198 unsigned int real_num_rx_queues;
1199
1200 #ifdef CONFIG_RFS_ACCEL
1201
1202
1203
1204 struct cpu_rmap *rx_cpu_rmap;
1205 #endif
1206 #endif
1207
1208 rx_handler_func_t __rcu *rx_handler;
1209 void __rcu *rx_handler_data;
1210
1211 struct netdev_queue __rcu *ingress_queue;
1212
1213
1214
1215
1216 struct netdev_queue *_tx ____cacheline_aligned_in_smp;
1217
1218
1219 unsigned int num_tx_queues;
1220
1221
1222 unsigned int real_num_tx_queues;
1223
1224
1225 struct Qdisc *qdisc;
1226
1227 unsigned long tx_queue_len;
1228 spinlock_t tx_global_lock;
1229
1230 #ifdef CONFIG_XPS
1231 struct xps_dev_maps __rcu *xps_maps;
1232 #endif
1233
1234
1235
1236
1237
1238
1239
1240 unsigned long trans_start;
1241
1242 int watchdog_timeo;
1243 struct timer_list watchdog_timer;
1244
1245
1246 int __percpu *pcpu_refcnt;
1247
1248
1249 struct list_head todo_list;
1250
1251 struct hlist_node index_hlist;
1252
1253 struct list_head link_watch_list;
1254
1255
1256 enum { NETREG_UNINITIALIZED=0,
1257 NETREG_REGISTERED,
1258 NETREG_UNREGISTERING,
1259 NETREG_UNREGISTERED,
1260 NETREG_RELEASED,
1261 NETREG_DUMMY,
1262 } reg_state:8;
1263
1264 bool dismantle;
1265
1266 enum {
1267 RTNL_LINK_INITIALIZED,
1268 RTNL_LINK_INITIALIZING,
1269 } rtnl_link_state:16;
1270
1271
1272 void (*destructor)(struct net_device *dev);
1273
1274 #ifdef CONFIG_NETPOLL
1275 struct netpoll_info *npinfo;
1276 #endif
1277
1278 #ifdef CONFIG_NET_NS
1279
1280 struct net *nd_net;
1281 #endif
1282
1283
1284 union {
1285 void *ml_priv;
1286 struct pcpu_lstats __percpu *lstats;
1287 struct pcpu_tstats __percpu *tstats;
1288 struct pcpu_dstats __percpu *dstats;
1289 };
1290
1291 struct garp_port __rcu *garp_port;
1292
1293
1294 struct device dev;
1295
1296 const struct attribute_group *sysfs_groups[4];
1297
1298
1299 const struct rtnl_link_ops *rtnl_link_ops;
1300
1301
1302 #define GSO_MAX_SIZE 65536
1303 unsigned int gso_max_size;
1304 #define GSO_MAX_SEGS 65535
1305 u16 gso_max_segs;
1306
1307 #ifdef CONFIG_DCB
1308
1309 const struct dcbnl_rtnl_ops *dcbnl_ops;
1310 #endif
1311 u8 num_tc;
1312 struct netdev_tc_txq tc_to_txq[TC_MAX_QUEUE];
1313 u8 prio_tc_map[TC_BITMASK + 1];
1314
1315 #if IS_ENABLED(CONFIG_FCOE)
1316
1317 unsigned int fcoe_ddp_xid;
1318 #endif
1319 #if IS_ENABLED(CONFIG_NETPRIO_CGROUP)
1320 struct netprio_map __rcu *priomap;
1321 #endif
1322
1323 struct phy_device *phydev;
1324
1325
1326 int group;
1327 };
skb表示数据和头部信息
分配: alloc_skb() or dev_alloc_skb()
drivers use dev_alloc_skb()
释放: kfree_skb() and dev_kfree_skb()spor
三层
transport_header
network_header
mac_header
skb_transport_header(skb)
skb_network_header(skb)
skb_mac_header(skb)
// 路由
unsigned long _skb_refdst;
之前的
struct dst_entry *dst;
// 每个sbk只有一个dst,dst有两个重要的函数
0069 int (*input)(struct sk_buff*);
0070 int (*output)(struct sk_buff*);
而net_device表示网络接口卡
//接口的mtu值
unsigned mtu; unsigned char dev_addr[MAX_ADDR_LEN];
// 发送数据的函数
int (*hard_start_xmit) (struct sk_buff *skb,
0415 struct net_device *dev)
// 是否处于混合模式, 如果值大于1 用来支持多个sniffer client
int promiscuity;