究竟他在kernel里加了什么以支持mpls?

1 加了netlink相关命令和属性

MPLS_ATTR_ILM

MPLS_CMD_NEWILM


2 arp处加了mpls tunnel接口

ARPHRD_MPLS_TUNNEL

3 网卡中加入mpls属性

net_device

mpls_ptr

4 加了

RTA_SHIM (FIXME)

5 加了socket

AF_MPLS

6 加了

NET_MPLS

7 fib_config里加了rt_shim

8 fib表的操作是大头 rtm_to_fib_config

        case RTA_SHIM:
            memcpy(&cfg->fc_shim, nla_data(attr), nla_len(attr));

9 独立文件的增加

mpls.h

    MPLS_OP_POP,
    MPLS_OP_PEEK,
    MPLS_OP_PUSH,
    MPLS_OP_DLV,
    MPLS_OP_FWD,

标签操作

10 shim.h

内容?(FIXME)

11 net/mpls.h


/****************************************************************************
 * MPLS Interface "Extension"
 * In the current implementation the "all loved" net_device struct is
 * extended with one field struct mpls_interface (cast'd to void) called
 * mpls_ptr; This holds basically the "per interface" labelspace.
 ****************************************************************************/

struct mpls_interface {
    /*  
     * (any mif object)->list_out is a circular d-linked list. Each node
     * of this list is a NHLFE. NHLFE's are added to this list when adding a
     * OP_SET opcode to a nhlfe instruction array.
     *
     * list_add(&nhlfe->dev_entry, &mpls_if->list_out) : adds nhlfe to this
     * list.
     *
     * "List of all NHLFEs that use this device (e.g. eth0) as output"
     * cf. mpls_init.c
     */
    struct list_head list_out;
                             

    /*  
     * (any mif object)->list_in is a circular d-linked list. Each node
     * of this list is a ILM. ILM's are added to this list when
     */
    struct list_head list_in;  

    /*
     * Label Space for this interface
     */
    int  labelspace;  
};

要用到radix树

12

桥下操作 mplsbr, 桥下过滤 netfilter/mpls

13

shim操作

14

static struct mpls_prot_driver mpls4_driver = {
    .name            =    "ipv4",
    .family                 =       AF_INET,
    .ethertype              =       __constant_htons(ETH_P_IP),
    .cache_flush            =       mpls4_cache_flush,
    .set_ttl                =       mpls4_set_ttl,
    .get_ttl                =       mpls4_get_ttl,
    .change_dsfield         =       mpls4_change_dsfield,
    .get_dsfield            =       mpls4_get_dsfield,
    .ttl_expired            =       mpls4_ttl_expired,
    .mtu_exceeded        =    mpls4_mtu_exceeded,
    .local_deliver        =    mpls4_local_deliver,
    .nexthop_resolve        =       mpls4_nexthop_resolve,
    .owner                  =       THIS_MODULE,
};

15

xt_mpls 原来是netfilter

总体上,我不知道他干了什么?我猜,kernel的作用就是解释netlink发来的路由信息

FIXME



你可能感兴趣的:(究竟他在kernel里加了什么以支持mpls?)