zoukankan      html  css  js  c++  java
  • vpp sr mpls policy

    https://vpp.flirble.org/stable-1801/srmpls_doc.html

    vpp# show sr mpls policies                                                           
    SR MPLS policies:
     
    vpp# show version
    vpp v20.05.1-release built by root on ff1827471f2b at 2020-07-15T20:14:36
    vpp# 

    vpp# mpls local-label add 102 non-eos via 192.168.123.2 GigabitEthernet7/0/0 out-labels 102                      
    vpp# sh mpls fib 102                                                                       
    MPLS-VRF:0, fib_index:0 locks:[CLI:2, ]
    102:neos/21 fib:0 index:25 locks:2
      CLI refs:1 src-flags:added,contributing,active,
        path-list:[31] locks:2 flags:shared, uPRF-list:12 len:1 itfs:[1, ]
          path:[33] pl-index:31 ip4 weight=1 pref=0 attached-nexthop:  oper-flags:resolved,
            192.168.123.2 GigabitEthernet7/0/0
          [@0]: ipv4 via 192.168.123.2 GigabitEthernet7/0/0: mtu:9000 next:3 5254007355cd5254005d14110800
        Extensions:
         path:33  labels:[[102 pipe ttl:0 exp:0]]
     forwarding:   mpls-neos-chain
      [@0]: dpo-load-balance: [proto:mpls index:28 buckets:1 uRPF:12 to:[0:0]]
        [0] [@6]: mpls-label[@1]:[102:64:0:neos]
            [@1]: mpls via 192.168.123.2 GigabitEthernet7/0/0: mtu:9000 next:2 5254007355cd5254005d14118847
    vpp# 
    vpp# sr mpls policy add bsid 40001 next 16001 next 16002 next 16003
    vpp# show sr mpls policies
    SR MPLS policies:
    [0].-   BSID: 40001
            TE disabled
            Type: Default
            Segment Lists:
            [0].- < 16001, 16002, 16003 > 
    -----------
    vpp# sr mpls policy del bsid 40001
    vpp# show sr mpls policies        
    SR MPLS policies:
    vpp# 
    vpp# sr mpls policy add bsid 40001 next 16001 next 16002 next 16003                                              
    vpp# sh mpls fib 16001                                             
    MPLS-VRF:0, fib_index:0 locks:[SR:1, CLI:2, recursive-resolution:1, ]
    16001:neos/21 fib:0 index:27 locks:3
      recursive-resolution refs:1 src-flags:added,contributing,active, cover:-1
        path-list:[33] locks:2 flags:drop, uPRF-list:29 len:0 itfs:[]
          path:[35] pl-index:33 mpls weight=1 pref=0 special:  cfg-flags:drop,
            [@0]: dpo-drop mpls
    
     forwarding:   mpls-neos-chain
      [@0]: dpo-load-balance: [proto:mpls index:31 buckets:1 uRPF:29 to:[0:0]]
        [0] [@0]: dpo-drop mpls
    vpp# sh mpls fib 16002
    MPLS-VRF:0, fib_index:0 locks:[SR:1, CLI:2, recursive-resolution:1, ]
    vpp# sh mpls fib 16003
    MPLS-VRF:0, fib_index:0 locks:[SR:1, CLI:2, recursive-resolution:1, ]
    vpp# show sr mpls policies                                         
    SR MPLS policies:
    [0].-   BSID: 40001
            TE disabled
            Type: Default
            Segment Lists:
            [0].- < 16001, 16002, 16003 > 
    -----------
    vpp# 

    https://wiki.fd.io/view/VPP/MPLS_FIB

    Basics
    MPLS is not enabled by default. There are two steps to get started. First, create the default MPLS FIB:
    
    mpls table add 0--------------------------不同于ip table add 2
    With '0' being the magic number for the 'default' table (just like it is for IPv[46]). One can create other MPLS tables, but, unlike IP tables, one cannot 'bind' non-default MPLS tables to interfaces, in other words all MPLS packets received on an interface will always result in a lookup in the default table. One has to be more inventive to use the non-default tables...
    
    Secondly, for *each* interface on which you wish to *receive* MPLS packets, that interface must be MPLS 'enabled'
    
    set interface mpls GigEthernet0/0/0 enable
    there is no equivalent enable for transmit, all that is required is to use an interface as an egress path.
    
    Entries in the MPLS FIB can be display with:
    
     sh mpls fib [table X] [label]
    
    MPLS FIB
    There is a tight coupling between IP and MPLS forwarding. MPLS forwarding equivalence classes (FECs) are often an IP prefix – that is to say that traffic matching a given IP prefix is routed into a MPLS label switch path (LSP). It is thus necessary to be able to associated a given prefix/route with an [out-going] MPLS label that will be imposed when the packet is forwarded. This is configured as:
    
    ip route add 1.1.1.1/32 via 10.10.10.10 GigE0/0/0 out-labels 33
    packets matching 1.1.1.1/32 will be forwarded out GigE0/0/0 and have MPLS label 33 imposed. More than one out-going label can be specified. Out-going MPLS labels can be applied to recursive and non-recursive routes, e.g;
    
    ip route add 2.2.2.0/24 via 1.1.1.1 out-labels 34
    packets matching 2.2.2.0/24 will thus have two MPLS labels imposed; 34 and 33. This is the realisation of, e,g, an MPLS BGP VPNv4. To associate/allocate a local-label for a prefix, and thus have packets to that local-label forwarded equivalently to the prefix do;
    
    mpls local-label 99 2.2.2.0/24
    In the API this action is called a ‘bind’. The router receiving the MPLS encapsulated packets needs to be programmed with actions associated which each label value – this is the role of the MPLS FIB. The MPLS FIB Is a table, whose key is the MPLS label value and end-of-stack (EOS) bit, which stores the action to perform on packets with matching encapsulation. Currently supported actions are:
    
    1)    Pop the label and perform an IPv[46] lookup in a specified table
    2)    Pop the label and forward via a specified next-hop (this is penultimate-hop-pop, PHP)
    3)    Swap the label and forward via a specified next-hop.
    These can be programmed respectively by:
    
    1)    mpls local-label 33 eos ip4-lookup-in-table X
    2)    mpls local-label 33 [eos] via 10.10.10.10 GigE0/0/0
    3)    mpls local-label 33 [eos] via 10.10.10.10 GigE0/0/0 out-labels 66
    the latter is an example of an MPLS cross connect. Any description of a next-hop, recursive, non-recursive, labelled, non-labelled, etc, that is valid for an IP prefix, is also valid for an MPLS local-label. Note the use of the 'eos' keyword which indicates the programming is for the case when the label is end-of-stack. The last two operations can apply to both eos and non-eos packets, but the pop and IP lookup only to an eos packet.
    
    MPLS VPN
    To configure an MPLS VPN for a PE the follow example can be used.
    
    Step 1; Configure routes to the iBGP peers - note these route MUST have out-going labels;
    
    ip route add 10.0.0.1/32 via 192.168.1.2 Eth0 out-labels 33
    ip route add 10.0.0.2/32 via 192.168.2.2 Eth0 out-labels 34
    Step 2; Configure the customer 'VRF'
    
    ip table add 2
    Step 3; add a route via the iBGP peer[s] with the MPLS label advertised by that peer
    
    ip route add table 2 10.10.10.0/24 via 10.0.0.2 next-hop-table 0 out-label 122
    ip route add table 2 10.10.10.0/24 via 10.0.0.1 next-hop-table 0 out-label 121
    Step 4; add a route via the eBGP peer
    
    ip route add table 2 10.10.20.0/24 via 172.16.0.1 next-hop-table 2
    Step 5; depending on the label allocation scheme used, add routes to the MPLS FIB to accept incoming labelled packets
    
    1 per-prefix label scheme - this command 'binds' the label to the same forwarding as the IP route
    
    mpls local-label 99 10.10.20.0/24 
    2 per-CE label scheme - this pops the incoming label. Append config for 'out-labels' if so desired.
    
    mpls local-label 99 via 172.16.0.1 next-hop-table 2
    3 per-VRF label scheme
    
    mpls local-label 99 via ip4-lookup-in-table 2
    Tunnels
    MPLS tunnels are unidirectional and can impose a stack of labels. They are 'normal' interfaces and thus can be used, for example, as the target for IP routes and L2 cross-connects. To construct a tunnel
    
    mpls tunnel via 10.10.10.10 GigEthernet0/0/0 out-labels 33 44 55
    and to then have that created tunnel to perform ECMP:
    
    mpls tunnel mpls-tunnel0 via 10.10.10.11 GigEthernet0/0/0 out-labels 66 77 88
    use
    
    sh mpls tunnel [X]
    to see the monster you have created. An MPLS tunnel interface is an interface like any other and now ready for use with the usual set of interface commands, e.g.:
    
    set interface state mpls-tunnel0 up
    set interface ip address mpls-tunnel0 192.168.1.1/30
  • 相关阅读:
    网络安全专家教你设置史上最安全的WiFi密码
    Python语言为什么被称为高级程序设计语言?
    常用组件
    小程序路由
    小程序的生命周期函数
    小程序案例-查询天气
    第一个小程序,获取用户名和用户头像
    小程序util.js的使用
    小程序文件夹目录分析 转
    特效 css3 渐变背景框
  • 原文地址:https://www.cnblogs.com/dream397/p/13540328.html
Copyright © 2011-2022 走看看