ºìÁªLinuxÃÅ»§
Linux°ïÖú

ÉîÈëÀí½âLinuxÍøÂç¼¼ÊõÄÚÄ»--¶ÁÊé±Ê¼Ç-----¹Ø¼üÊý¾Ý½á¹¹

·¢²¼Ê±¼ä:2011-11-21 10:56:36À´Ô´:ºìÁª×÷Õß:sky001
Ò». sk_buff
¡¡¡¡LinuxÍøÂçЭÒéÕ»ÖÐÖ÷ÒªµÄ»º´æÀàÐÍ¡£¶¨ÒåÔÚinclude/linux/skbuff.hÖУ¬ËüÊÇÒ»¸öË«ÏòÁ´±íµÄÊý¾Ý½á¹¹¡£ËüµÄ×ֶκͺ¯ÊýÖ÷Òª·ÖΪËÄ´óÀࣺ
¡¡¡¡1. ²¼¾Ö×ֶΣºÓëÕû¸ösk_buffÁ´±í½á¹¹Ïà¹ØµÄ×Ö¶Î
2. ͨÓÃÐÅÏ¢×ֶΣº
3. ÌØÐÔÏà¹Ø×ֶΣº
4. ¹ÜÀí¹¦Äܺ¯Êý£º
¶þ. sk_buff²¼¾Ö×Ö¶Î
ΪÁ˺ܿìµØÕÒµ½sk_buffÁ´±íÖеıíÍ·£¬Ã¿¸öÁ´±íÖж¼ÓÐÒ»¸öÕâÑùµÄ×ֶΣº
struct sk_buff_head *list;
Õâ¸öÓòÊÇÖ¸Ïòsk_buffÁ´±íÍ·µÄÖ¸Õë¡£
struct sk_buff_head {
/* These two members must be first. */
struct sk_buff *next;
struct sk_buff *prev;
¡¡¡¡__u32 qlen;
¡¡¡¡spinlock_t lock;
};
¡¡¡¡ÆäÖÐqlenΪÁ´±í³¤¶È£¬lockÊÇÓëÁ´±í¹ÜÀíÏà¹ØµÄ×Ö¶Î
Õû¸öÁ´±íµÄ½á¹¹ÈçÏ£º

ÆäËû×Ö¶ÎÈçÏ£º
¡¡¡¡struct sock *sk; L4ÐèÒªµÄ×ֶΣ¬´æ´¢ÓëÖ®Ïà¹ØµÄsocketÐÅÏ¢£¬ÔÚÆäËû²ã¸Ã×Ö¶ÎΪNULL
¡¡¡¡unsigned int len; bufferÖÐÊý¾ÝµÄ³¤¶È£¬°üÀ¨head->nextÖ¸ÏòµÄÖ÷³¤¶ÈºÍ·ÖƬ³¤¶È
¡¡¡¡unsigned int data_len; ²»Í¬ÓÚÉÏ£¬¸Ã×Ö¶ÎÖ»Ö¸·ÖƬÊý¾ÝµÄ³¤¶È
¡¡¡¡unsigned int mac_len; macÍ·²¿³¤¶È
¡¡¡¡atomic_t users; ÒýÓüÆÊý£¬·ÀÖ¹ÔÚÓÐÆäËû³ÌÐòÒýÓøÃbufferʱ±»ÊÍ·Å
¡¡¡¡unsigned int truesize; ±íʾbufferµÄËùÓг¤¶È£¬°üÀ¨sk_buff½á¹¹×ÔÉíµÄ³¤¶È
unsigned char *head; unsigned char *end; unsigned char *data; unsigned char *tail; ÕâËĸöÖ¸Õ빦ÄÜÈçÏÂ

void (*destructor)(...) µ±buff±»ÊÍ·Åʱ£¬º¯ÊýÖ¸Õë¿ÉÒÔ½øÐÐijЩ¹¤×÷
Èý. ͨÓÃÐÅÏ¢×Ö¶Î
¡¡¡¡struct timeval stamp; ±¨ÎĽÓÊÕµÄʱ¼ä
¡¡¡¡struct net_device *dev; ¸ù¾Ý½ÓÊÕµ½ÁË°ü»òÕßÊÇÒª·¢ËÍ°ü£¬¸ÃÖ¸ÕëÖ¸ÏòµÄÉ豸Ëù°çÑݵĽÇÉ«²»Í¬
¡¡¡¡struct net_device *input_dev; °üÊÇ´ÓÄĸöÉ豸½ÓÊÕµÄ
¡¡¡¡struct net_device *real_dev; ¶ÔÓÚÐéÄâÉ豸Õâ¸ö×ֶβÅÊÇÓÐÒâÒåµÄ
¡¡¡¡union {...} h; union {...} nh; union {...} mac hÊÇL4µÄÍ·²¿£¬nhÊÇL3µÄÍ·²¿£¬macÊÇL2µÄÍ·²¿¡£ÔÚ°üÏòÉÏ»òÕßÏòÏ´«µÝ¹ý³ÌÖУ¬ÕâЩÓò»á±»ÒÀ´ÎÓÐÐòµØÉèÖÃ

¡¡¡¡struct dst_entry dst; ·ÓÉÏà¹ØµÄ×Ö¶Î
¡¡¡¡char cb[40]; ´æ·Åÿ²ã˽ÓеĿØÖÆÊý¾Ý
unsigned int csum; unsigned char ip_summed ¼ìÑéºÍÏà¹Ø״̬µÄ×Ö¶Î
unsigned char cloned; ÊÇ·ñÊÇ´Ó±ðµÄbuffer¸´ÖƹýÀ´µÄ
unsigned char pkt_type; ±¨ÎÄÀàÐÍ£¬Ïê¼ûinclude/linux/if_packet.h

ËÄ. ÌØÐÔÏà¹Ø×Ö¶Î
Èç¹ûÏ£ÍûΪLinuxÄÚºËÅäÖöîÍâÖ§³Ö·À»ðǽ»òÕßQoSµÄ¹¦ÄÜ£¬ÄÇô¾ÍÐèÒªÔÚÅäÖÃÎļþÖÐÅäÖÃÏà¹ØÐÅÏ¢£¬ÒÔ±ãÔÚ±àÒë½×¶Î°ÑÌØÐÔÏà¹ØµÄ×Ö¶ÎÒýÈëµ½sk_buffÖÐ
ÎÄÕÂÆÀÂÛ

¹²ÓÐ 12 ÌõÆÀÂÛ

  1. zhangpeijun ÓÚ 2012-10-29 13:49:13·¢±í:

    Ä¿Ç°»¹ÊDzËÄñµÄÎÒ£¬ÍêÈ«¿´²»¶®¡£

  2. viforce ÓÚ 2012-07-26 20:22:55·¢±í:

    (o):tx0:w(5(

  3. Ò»Ò³¿ÕÖ½ ÓÚ 2011-11-27 16:08:35·¢±í:

    Å£ÈËѽ£¡°ñÑù¡£¡£¡£

  4. chly64 ÓÚ 2011-11-23 21:28:16·¢±í:

    лл¥Ö÷

  5. chly64 ÓÚ 2011-11-23 21:28:14·¢±í:

    лл¥Ö÷

  6. chly64 ÓÚ 2011-11-23 21:28:10·¢±í:

    лл¥Ö÷

  7. chly64 ÓÚ 2011-11-23 21:28:08·¢±í:

    лл¥Ö÷

  8. chly64 ÓÚ 2011-11-23 21:28:06·¢±í:

    лл¥Ö÷

  9. chly64 ÓÚ 2011-11-23 21:28:05·¢±í:

    лл¥Ö÷

  10. chly64 ÓÚ 2011-11-23 21:05:40·¢±í:

    лл

  11. badgc ÓÚ 2011-11-21 11:18:16·¢±í:

    Ç¿ÈË°¡

  12. sky001 ÓÚ 2011-11-21 10:57:14·¢±í:

    ѧϰ½»Á÷Ⱥ£º146762986