File:  [NetBSD Developer Wiki] / wikisrc / users / kefren / mpls.mdwn
Revision 1.1: download - view: text, annotated - select for diffs
Sun Jul 4 20:22:25 2010 UTC (3 years, 9 months ago) by wiki
Branches: MAIN
CVS tags: HEAD
web commit by kefren

#Some quick info about MPLS:

You need to compile your kernel with options MPLS and psuedo-device ifmpls
For pure LSR - that only switch labels without encap/decap from other protocols (e.g. INET) you need only to work on routing table. For example:

<pre># route add -mpls 41 -tag 25 -inet 193.28.151.97
add host 41: gateway 193.28.151.97
# route add -mpls 42 -tag 30 -inet 193.28.151.97
add host 42: gateway 193.28.151.97
# route add -mpls 51 -tag 25 -inet 193.28.151.97
add host 51: gateway 193.28.151.97</pre>

Translation of first line: if it receives an MPLS frame with label 41 forward it to INET next-hop 193.28.151.97, tagged with label 25

You also need to tweak sysctl to accept and forward MPLS:

<pre># sysctl -w net.mpls.accept=1
net.mpls.accept: 0 -> 1
# sysctl -w net.mpls.forwarding=1
net.mpls.forwarding: 0 -> 1</pre>


Verify routes with route get or better with netstat -nrT:

<pre>
...
MPLS:
Destination        Gateway            Flags    Refs      Use    Mtu     Tag Interface
41                 193.28.151.97      UGHS        0    37241      -      25 sk0
42                 193.28.151.97      UGHS        0        0      -      30 sk0
51                 193.28.151.97      UGHS        0        0      -      25 sk0
</pre>

#Interacting with other protocols

If you want to also decapsulate/encapsulate from MPLS to some other protocol (like INET or INET6), you have to create an mpls interface and put in up: ifconfig mpls0 create up. YOU NEED TO ADD AN ADDRESS OF THAT PROTOCOL ON THIS INTERFACE - whenever that address is private or not.

E.g. for INET - setting a fictitious address:

<pre>
# ifconfig mpls0 create up
# ifconfig mpls0 1.1.1.1/32
</pre>

After that create routes like this - use -ifa flag in order to avoid self-generated packets having source address 1.1.1.1, but route them thru mpls0 interface.

<pre>
# route add 204.152.190.0/24 -ifa 193.28.151.105 -ifp mpls0 -tag 25 -inet 193.28.151.97
add net 204.152.190.0: gateway 193.28.151.97
</pre>

Verify the route:

<pre>
# route -n get 204.152.190.0/24
   route to: 204.152.190.0
destination: 204.152.190.0
       mask: 255.255.255.0
    gateway: 193.28.151.97
        Tag: 25
 local addr: 193.28.151.105
  interface: mpls0
      flags: <UP,GATEWAY,DONE,STATIC>
 recvpipe  sendpipe  ssthresh  rtt,msec    rttvar  hopcount      mtu     expire
       0         0         0       813       344         0         0         0 
sockaddrs: <DST,GATEWAY,NETMASK,IFP,IFA,TAG>
</pre>

or with netstat -rT:
<pre>
...
204.152.190/24     193.28.151.97      UGS         0    95362      -      25 mpls0
...
</pre>


I'm working on [[LDP]] daemon, it should be available in src tree in a couple of months. You may still want to test the beta.

CVSweb for NetBSD wikisrc <wikimaster@NetBSD.org> software: FreeBSD-CVSweb