Skip to content

Instantly share code, notes, and snippets.

@takehaya
Last active May 18, 2023 00:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save takehaya/8170122cb7ff4c710775d02123903e70 to your computer and use it in GitHub Desktop.
Save takehaya/8170122cb7ff4c710775d02123903e70 to your computer and use it in GitHub Desktop.
Usage of exabgp BGP-MUP Support

BGP Extensions for the Mobile User Plane (MUP) SAFI for exaBGP

https://datatracker.ietf.org/doc/html/draft-mpmz-bess-mup-safi-02

This document shows an example of interconnection between GoBGP and exaBGP, which are existing implementations of SRv6MUP.

Setup netns

write by testnet.sh

#!/bin/bash
set -eu

if [[ $(id -u) -ne 0 ]] ; then
    echo "Please run with sudo"
    exit 1
fi

run () {
    echo "$@"
    "$@" || exit 1
}

destroy_network () {
    run ip netns del red
    run ip netns del blue
}

stop () {
    destroy_network
}

trap stop 0 1 2 3 13 14 15

# exec functions
run ip link add veth-red-blue type veth peer name veth-blue-red

run ip netns add red
run ip link set veth-red-blue netns red
run ip netns exec red ip link set up lo
run ip netns exec red ip link set up veth-red-blue 
run ip netns exec red ip addr add 10.0.0.1/24 dev veth-red-blue 

run ip netns add blue
run ip link set veth-blue-red netns blue
run ip netns exec blue ip link set up lo
run ip netns exec blue ip link set up veth-blue-red
run ip netns exec blue ip addr add 10.0.0.2/24 dev veth-blue-red

status=0; $SHELL || status=$?
exit $status
sudo ./testnet.sh

Exabgp config

neighbor 10.0.0.2 {
	router-id 10.0.0.1;
	local-address 10.0.0.1;
	local-as 65000;
	peer-as 65000;

	family {
        ipv4 mup;
        ipv6 mup;
	}
	announce {
		ipv4 {
			mup \
			mup-isd 10.0.1.0/24 rd 100:100 \
			next-hop 2001::1 \
			extended-community [ target:10:10 ] \
			bgp-prefix-sid-srv6 ( l3-service 2001:db8:1:1:: 0x48 [64,24,16,0,0,0] );

			mup \
			mup-dsd 10.0.0.1 rd 100:100 \
			next-hop 2001::2 \
			extended-community [ target:10:10 mup:10:10 ] \
			bgp-prefix-sid-srv6 ( l3-service 2001:db8:1:1:: 0x13 [64,24,16,0,0,0] );
			
			mup \
			mup-t1st 192.168.0.1/32 rd 100:100 teid 12345 qfi 9 endpoint 10.0.0.1 \
			next-hop 10.0.0.2 \
			extended-community [ target:10:10 ];

			mup \
			mup-t2st 10.0.0.1 rd 100:100 teid 12345/32 \
			next-hop 10.0.0.2 \
			extended-community [ target:10:10 mup:10:10 ];
		}
		ipv6 {
			mup \
			mup-isd 2001::/64 rd 100:100 \
			next-hop 2001::2 \
			extended-community [ target:10:10 ] \
			bgp-prefix-sid-srv6 ( l3-service 2001:db8:1:1:: 0x47 [64,24,16,0,0,0] );

			mup \
			mup-dsd 2001::1 rd 100:100 \
			next-hop 2001::2 \
			extended-community [ target:10:10 mup:10:10 ] \
			bgp-prefix-sid-srv6 ( l3-service 2001:db8:2:2:: 0x18 [64,24,16,0,0,0] );
			
			mup \
			mup-t1st 2001:db8:1:1::1/128 rd 100:100 teid 12345 qfi 9 endpoint 2001::1\
			next-hop 10.0.0.2 \
			extended-community [ target:10:10 ];

			mup \
			mup-t2st 2001::1 rd 100:100 teid 12345/32 \
			next-hop 10.0.0.2 \
			extended-community [ target:10:10 mup:10:10 ];
		}
	}
}

NOTE: If you run Exabgp in your environment, you may need to set the pid as follows

exabgp env > /home/ubuntu/exabgp/etc/exabgp/exabgp.env
mkdir -p /home/ubuntu/exabgp/var/run/exabgp/
mkfifo /var/run/exabgp/exabgp.{in,out}
chmod 666 /var/run/exabgp/exabgp.{in,out}

Gobgpd config

[global.config]
    as = 65000
    router-id = "10.0.0.2"
    local-address-list = ["10.0.0.2"]

[[neighbors]]
    [neighbors.config]
        peer-as = 65000
        local-as = 65000
        neighbor-address = "10.0.0.1"
    [[neighbors.afi-safis]]
        [neighbors.afi-safis.config]
            afi-safi-name = "ipv4-mup"
    [[neighbors.afi-safis]]
        [neighbors.afi-safis.config]
            afi-safi-name = "ipv6-mup"

Start gobgpd

sudo ip netns exec blue gobgpd -f ./blue.toml

Start exabgp(and announce mup)

sudo ip netns exec red ./sbin/exabgp ./red.conf

Show MUPRoutes(announced exabgp)

IPv4&IPv6(send exabgp)

sudo ip netns exec red \
  /home/ubuntu/exabgp/bin/exabgpcli \
  show adj-rib out
command: show adj-rib out
neighbor 10.0.0.2 ipv4 mup mup:isd::100:100:10.0.1.0/24
neighbor 10.0.0.2 ipv4 mup mup:dsd::100:100:10.0.0.1
neighbor 10.0.0.2 ipv4 mup mup:t1st::100:100:192.168.0.1/32:12345:9:32:10.0.0.1
neighbor 10.0.0.2 ipv4 mup mup:t2st::100:100:12345:32:10.0.0.1
neighbor 10.0.0.2 ipv6 mup mup:isd::100:100:2001::/64
neighbor 10.0.0.2 ipv6 mup mup:dsd::100:100:2001::1
neighbor 10.0.0.2 ipv6 mup mup:t1st::100:100:2001:db8:1:1::1/128:12345:9:128:2001::1
neighbor 10.0.0.2 ipv6 mup mup:t2st::100:100:12345:128:2001::1

IPv4(recv gobgp)

sudo ip netns exec blue gobgp neighbor 10.0.0.1 adj-in -a ipv4-mup 
   ID  Network                                            TEID       QFI        Endpoint             Next Hop             AS_PATH              Age        Attrs
   0   [type:dsd][rd:100:100][prefix:10.0.0.1]                                                       2001::2                                   00:21:52   [{Origin: i} {LocalPref: 100} {Extcomms: [10:10]} {Prefix SID attributes: {SRv6 L3 Service Attribute: {SRv6 Information Sub TLV: SID: 2001:db8:1:1:: Flag: 0 Endpoint Behavior: 19 {SRv6 Structure Sub Sub TLV: [ Locator Block Length: 64, Locator Node Length: 24, Function Length: 16, Argument Length: 0, Transposition Length: 0, Transposition Offset: 0] } } } }]
   0   [type:t1st][rd:100:100][prefix:192.168.0.1/32]     12345      9          10.0.0.1             10.0.0.2                                  00:21:52   [{Origin: i} {LocalPref: 100} {Extcomms: [10:10]}]
   0   [type:t2st][rd:100:100][endpoint:10.0.0.1][teid:0]                                            10.0.0.2                                  00:21:52   [{Origin: i} {LocalPref: 100} {Extcomms: [10:10]}]
   0   [type:isd][rd:100:100][prefix:10.0.1.0/24]                                                    2001::1                                   00:21:52   [{Origin: i} {LocalPref: 100} {Extcomms: [10:10]} {Prefix SID attributes: {SRv6 L3 Service Attribute: {SRv6 Information Sub TLV: SID: 2001:db8:1:1:: Flag: 0 Endpoint Behavior: 72 {SRv6 Structure Sub Sub TLV: [ Locator Block Length: 64, Locator Node Length: 24, Function Length: 16, Argument Length: 0, Transposition Length: 0, Transposition Offset: 0] } } } }]

IPv6(recv gobgp)

sudo ip netns exec blue gobgp neighbor 10.0.0.1 adj-in -a ipv6-mup 
   ID  Network                                             TEID       QFI        Endpoint             Next Hop             AS_PATH              Age        Attrs
   0   [type:isd][rd:100:100][prefix:2001::/64]                                                       2001::2                                   00:22:22   [{Origin: i} {LocalPref: 100} {Extcomms: [10:10]} {Prefix SID attributes: {SRv6 L3 Service Attribute: {SRv6 Information Sub TLV: SID: 2001:db8:1:1:: Flag: 0 Endpoint Behavior: 71 {SRv6 Structure Sub Sub TLV: [ Locator Block Length: 64, Locator Node Length: 24, Function Length: 16, Argument Length: 0, Transposition Length: 0, Transposition Offset: 0] } } } }]
   0   [type:dsd][rd:100:100][prefix:2001::1]                                                         2001::2                                   00:22:22   [{Origin: i} {LocalPref: 100} {Extcomms: [10:10]} {Prefix SID attributes: {SRv6 L3 Service Attribute: {SRv6 Information Sub TLV: SID: 2001:db8:2:2:: Flag: 0 Endpoint Behavior: 24 {SRv6 Structure Sub Sub TLV: [ Locator Block Length: 64, Locator Node Length: 24, Function Length: 16, Argument Length: 0, Transposition Length: 0, Transposition Offset: 0] } } } }]
   0   [type:t1st][rd:100:100][prefix:2001:db8:1:1::1/128] 12345      9          2001::1              10.0.0.2                                  00:22:22   [{Origin: i} {LocalPref: 100} {Extcomms: [10:10]}]
   0   [type:t2st][rd:100:100][endpoint:2001::1][teid:0]                                              10.0.0.2                                  00:22:22   [{Origin: i} {LocalPref: 100} {Extcomms: [10:10]}]

Announce mup(from gobgp)

IPv4

sudo ip netns exec blue \
    gobgp global rib add \
        -a ipv4-mup \
        isd 10.0.1.0/24 \
        rd 100:100 \
        prefix 2001:db8:1:1::/64 \
        locator-node-length 24 \
        function-length 16 \
        behavior ENDM_GTP4E \
        rt 10:10 \
        nexthop 2001::2
sudo ip netns exec blue \
    gobgp global rib add \
        -a ipv4-mup \
        dsd 10.0.1.1 \
        rd 100:100 \
        prefix 2001:db8:1:1::/64 \
        locator-node-length 24 \
        function-length 16 \
        behavior END_DT4 \
        rt 10:10 \
        mup 10:10 \
        nexthop 2001::2
sudo ip netns exec blue \
    gobgp global rib add \
        -a ipv4-mup \
        t1st 192.168.1.1/32 \
        rd 100:100 \
        rt 10:10 \
        teid 12345 \
        qfi 9 \
        endpoint 10.0.0.2 \
        nexthop 10.0.0.1
sudo ip netns exec blue \
    gobgp global rib add \
        -a ipv4-mup \
        t2st 10.0.0.2 \
        rd 100:100 \
        rt 10:10 \
        endpoint-address-length 64 \
        teid 12345 \
        mup 10:10 \
        nexthop 10.0.0.1

IPv6

sudo ip netns exec blue \
        gobgp global rib add \
        -a ipv6-mup isd 2002::/64 \
        rd 100:100 \
        prefix 2002:db8:1:1::/64 \
        locator-node-length 24 \
        function-length 16 \
        behavior ENDM_GTP6E \
        rt 10:10 \
        nexthop 2002::2
sudo ip netns exec blue \
    gobgp global rib add \
        -a ipv6-mup \
        dsd 2002::1 \
        rd 100:100 \
        prefix 2002:db8:2:2::/64 \
        locator-node-length 24 \
        function-length 16 \
        behavior END_DT6 \
        rt 10:10 \
        mup 10:10 \
        nexthop 2002::2
sudo ip netns exec blue \
    gobgp global rib add \
        -a ipv6-mup \
        t1st 2002:db8:1:1::1/128 \
        rd 100:100 \
        rt 10:10 \
        teid 12345 \
        qfi 9 \
        endpoint 2002::1 \
        nexthop 10.0.0.1
sudo ip netns exec blue \
    gobgp global rib add \
        -a ipv6-mup \
        t2st 2002::1 \
        rd 100:100 \
        rt 10:10 \
	endpoint-address-length 160 \
        teid 12345 \
        mup 10:10 \
        nexthop 10.0.0.1

Show MUPRoutes(announced gobgp)

IPv4&IPv6(recv exabgp)

sudo ip netns exec red \
  /home/ubuntu/exabgp/bin/exabgpcli \
  show adj-rib int
command: show adj-rib in
neighbor 10.0.0.2 ipv4 mup mup:isd::100:100:10.0.1.0/24
neighbor 10.0.0.2 ipv4 mup mup:dsd::100:100:10.0.1.1
neighbor 10.0.0.2 ipv4 mup mup:t1st::100:100:192.168.1.1/32:48:9:32:10.0.0.2
neighbor 10.0.0.2 ipv4 mup mup:t2st::100:100:12345:64:10.0.0.2
neighbor 10.0.0.2 ipv6 mup mup:isd::100:100:2002::/64
neighbor 10.0.0.2 ipv6 mup mup:dsd::100:100:2002::1
neighbor 10.0.0.2 ipv6 mup mup:t1st::100:100:2002:db8:1:1::1/128:48:9:128:2002::1
neighbor 10.0.0.2 ipv6 mup mup:t2st::100:100:12345:160:2002::1

IPv4(send gobgp)

sudo ip netns exec blue gobgp neighbor 10.0.0.1 adj-out -a ipv4-mup 
   ID  Network                                                TEID       QFI        Endpoint             Next Hop             AS_PATH              Attrs
   1   [type:dsd][rd:100:100][prefix:10.0.1.1]                                                           2001::2                                   [{Origin: ?} {LocalPref: 100} {Extcomms: [10:10], [10:10]} {Prefix SID attributes: {SRv6 L3 Service Attribute: {SRv6 Information Sub TLV: SID: 2001:db8:1:1:: Flag: 0 Endpoint Behavior: 19 {SRv6 Structure Sub Sub TLV: [ Locator Block Length: 64, Locator Node Length: 24, Function Length: 16, Argument Length: 0, Transposition Length: 0, Transposition Offset: 0] } } } }]
   1   [type:t1st][rd:100:100][prefix:192.168.1.1/32]         12345      9          10.0.0.2             10.0.0.1                                  [{Origin: ?} {LocalPref: 100} {Extcomms: [10:10]}]
   1   [type:t2st][rd:100:100][endpoint:10.0.0.2][teid:12345]                                            10.0.0.1                                  [{Origin: ?} {LocalPref: 100} {Extcomms: [10:10], [10:10]}]
   2   [type:isd][rd:100:100][prefix:10.0.1.0/24]                                                        2001::2                                   [{Origin: ?} {LocalPref: 100} {Extcomms: [10:10]} {Prefix SID attributes: {SRv6 L3 Service Attribute: {SRv6 Information Sub TLV: SID: 2001:db8:1:1:: Flag: 0 Endpoint Behavior: 72 {SRv6 Structure Sub Sub TLV: [ Locator Block Length: 64, Locator Node Length: 24, Function Length: 16, Argument Length: 0, Transposition Length: 0, Transposition Offset: 0] } } } }]

IPv6(send gobgp)

sudo ip netns exec blue gobgp neighbor 10.0.0.1 adj-out -a ipv6-mup 
   ID  Network                                               TEID       QFI        Endpoint             Next Hop             AS_PATH              Attrs
   1   [type:dsd][rd:100:100][prefix:2002::1]                                                           2002::2                                   [{Origin: ?} {LocalPref: 100} {Extcomms: [10:10], [10:10]} {Prefix SID attributes: {SRv6 L3 Service Attribute: {SRv6 Information Sub TLV: SID: 2002:db8:2:2:: Flag: 0 Endpoint Behavior: 18 {SRv6 Structure Sub Sub TLV: [ Locator Block Length: 64, Locator Node Length: 24, Function Length: 16, Argument Length: 0, Transposition Length: 0, Transposition Offset: 0] } } } }]
   1   [type:t1st][rd:100:100][prefix:2002:db8:1:1::1/128]   12345      9          2002::1              10.0.0.1                                  [{Origin: ?} {LocalPref: 100} {Extcomms: [10:10]}]
   1   [type:t2st][rd:100:100][endpoint:2002::1][teid:12345]                                            10.0.0.1                                  [{Origin: ?} {LocalPref: 100} {Extcomms: [10:10], [10:10]}]
   1   [type:isd][rd:100:100][prefix:2002::/64]                                                         2002::2                                   [{Origin: ?} {LocalPref: 100} {Extcomms: [10:10]} {Prefix SID attributes: {SRv6 L3 Service Attribute: {SRv6 Information Sub TLV: SID: 2002:db8:1:1:: Flag: 0 Endpoint Behavior: 71 {SRv6 Structure Sub Sub TLV: [ Locator Block Length: 64, Locator Node Length: 24, Function Length: 16, Argument Length: 0, Transposition Length: 0, Transposition Offset: 0] } } } }]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment