Allow the mpw(4) interface to establish VPLS tunnel over an IPv6-only MPLS
core.

This is the mpw(4) bit.

It requires the kernel diff from
https://marc.info/?l=openbsd-tech&m=154513171617201&w=2 to avoid panic.

---------------
pe1# cat /etc/ldpd.conf                                                        
router-id 10.1.1.1

address-family ipv6 {
        interface vio2
        interface vio1
        transport-address 2001:db8:ff::e1
}

l2vpn CUSTOMER type vpls {
        bridge bridge0
        interface vio0
        pseudowire mpw0 {
                pw-id 100
                neighbor-addr 2001:db8:ff::e2
                neighbor-id 10.2.2.2
        }
}
---------------
pe1# ifconfig mpw0       
mpw0: flags=51<UP,POINTOPOINT,RUNNING> mtu 1500
        index 7 priority 0 llprio 3
        encapsulation-type ethernet, control-word
        mpls label: local 16 remote 16
        neighbor: 2001:db8:ff::e2
        groups: mpw
---------------
p1# netstat -nr                                                                
Routing tables

Internet:
Destination        Gateway            Flags   Refs      Use   Mtu  Prio Iface
10.255.255.1       10.255.255.1       UHl        0        0 32768     1 lo0  

Internet6:
Destination                        Gateway                        Flags   Refs 
Use   Mtu  Prio Iface
::/96                              ::1                            UGRS       0 
0 32768     8 lo0  
::1                                ::1                            UHhl      14 
28 32768     1 lo0  
::ffff:0.0.0.0/96                  ::1                            UGRS       0 
0 32768     8 lo0  
2001:db8:1::/64                    2001:db8:1::2                  UCn        0 
0     -     4 vio0 
2001:db8:1::/64                    link#1                         UC         0 
0     -    32 vio0 
2001:db8:1::2                      fe:e1:bb:d1:b1:96              UHLl       0 
21     -     1 vio0 
2001:db8:2::/64                    2001:db8:2::2                  UCn        0 
0     -     4 vio1 
2001:db8:2::/64                    link#2                         UC         0 
0     -    32 vio1 
2001:db8:2::2                      fe:e1:bb:d2:64:cd              UHLl       0 
54     -     1 vio1 
2001:db8:3::/64                    fe80::fc50:3574:f600:b3d3%vio0 UG         0 
0     -    32 vio0 
2001:db8:4::/64                    fe80::fc50:3574:f600:b3d3%vio0 UGPT       0 
0     -    32 vio0 
2001:db8:4::/64                    fe80::823a:1629:36a5:de3%vio1  UGPT       0 
0     -    32 vio1 
2001:db8:5::/64                    fe80::823a:1629:36a5:de3%vio1  UG         0 
0     -    32 vio1 
2001:db8:ff::1                     2001:db8:ff::1                 UHl        0 
191 32768     1 lo0  
2001:db8:ff::2                     fe80::fc50:3574:f600:b3d3%vio0 UGHT       0 
0     -    32 vio0 
2001:db8:ff::3                     fe80::823a:1629:36a5:de3%vio1  UGHT       0 
0     -    32 vio1 
2001:db8:ff::e1                    fe80::fc50:3574:f600:b3d3%vio0 UGH        1 
3     -    32 vio0 
2001:db8:ff::e2                    fe80::823a:1629:36a5:de3%vio1  UGH        1 
1     -    32 vio1 
2002::/24                          ::1                            UGRS       0 
0 32768     8 lo0  
2002:7f00::/24                     ::1                            UGRS       0 
0 32768     8 lo0  
2002:e000::/20                     ::1                            UGRS       0 
0 32768     8 lo0  
2002:ff00::/24                     ::1                            UGRS       0 
0 32768     8 lo0  
fe80::/10                          ::1                            UGRS       0 
2 32768     8 lo0  
fec0::/10                          ::1                            UGRS       0 
0 32768     8 lo0  
fe80::%vio0/64                     fe80::be6c:60bc:74f0:eee9%vio0 UCn        1 
2     -     4 vio0 
fe80::be6c:60bc:74f0:eee9%vio0     fe:e1:bb:d1:b1:96              UHLl       0 
123     -     1 vio0 
fe80::fc50:3574:f600:b3d3%vio0     fe:e1:bb:d2:e8:90              UHLch      9 
921     -     3 vio0 
fe80::%vio1/64                     fe80::3022:e716:7dd9:db87%vio1 UCn        1 
2     -     4 vio1 
fe80::3022:e716:7dd9:db87%vio1     fe:e1:bb:d2:64:cd              UHLl       0 
113     -     1 vio1 
fe80::823a:1629:36a5:de3%vio1      fe:e1:bb:d2:18:7c              UHLch      8 
405     -     3 vio1 
fe80::1%lo0                        fe80::1%lo0                    UHl        0 
0 32768     1 lo0  
ff01::/16                          ::1                            UGRS       0 
2 32768     8 lo0  
ff01::%vio0/32                     fe80::be6c:60bc:74f0:eee9%vio0 Um         0 
1     -     4 vio0 
ff01::%vio1/32                     fe80::3022:e716:7dd9:db87%vio1 Um         0 
1     -     4 vio1 
ff01::%lo0/32                      fe80::1%lo0                    Um         0 
2 32768     4 lo0  
ff02::/16                          ::1                            UGRS       0 
2 32768     8 lo0  
ff02::%vio0/32                     fe80::be6c:60bc:74f0:eee9%vio0 Um         0 
1     -     4 vio0 
ff02::%vio1/32                     fe80::3022:e716:7dd9:db87%vio1 Um         0 
1     -     4 vio1 
ff02::%lo0/32                      fe80::1%lo0                    Um         0 
2 32768     4 lo0  

MPLS:
In label  Out label Op     Gateway            Flags   Refs      Use   Mtu  Prio 
Interface
16        -         LOCAL  ::1%4              UGT        0        0 32768     8 
lo0  
17        -         LOCAL  ::1%4              UGT        0        0 32768     8 
lo0  
18        -         LOCAL  ::1%4              UGT        0        0 32768     8 
lo0  
19        -         LOCAL  ::1%4              UGT        0        0 32768     8 
lo0  
111       23        SWAP   fe80::823a:1629:36a5:de3%vio1 UGPT       0        0 
-    32 vio1 
111       126       SWAP   fe80::fc50:3574:f600:b3d3%vio0 UGPT       0        0 
-    32 vio0 
116       -         POP    fe80::fc50:3574:f600:b3d3%vio0 UGT        0        0 
-    32 vio0 
117       -         POP    fe80::823a:1629:36a5:de3%vio1 UGT        0        0 
-    32 vio1 
118       128       SWAP   fe80::fc50:3574:f600:b3d3%vio0 UGT        0        0 
-    32 vio0 
119       26        SWAP   fe80::823a:1629:36a5:de3%vio1 UGT        0        0 
-    32 vio1 
120       -         POP    fe80::fc50:3574:f600:b3d3%vio0 UGT        0      602 
-    32 vio0 
121       -         POP    fe80::823a:1629:36a5:de3%vio1 UGT        0      614 
-    32 vio1 
---------------
p1# tcpdump -n -i vio0 mpls
tcpdump: listening on vio0, link-type EN10MB
16:48:23.638034 MPLS(label 121, exp 0, ttl 255) 2001:db8:ff::e1.646 > 
2001:db8:ff::e2.646: udp 54 [class 0xc0]                        
16:48:24.371544 MPLS(label 121, exp 0, ttl 255) 2001:db8:ff::e1.646 > 
2001:db8:ff::e2.27713: P 3778328966:3778328984(18) ack 1753071649 win 267 
<nop,nop,timestamp 1382884540 1202052298> [flowlabel 0x23afd]
16:48:24.884135 MPLS(label 121, exp 0, ttl 255) 2001:db8:ff::e1.646 > 
2001:db8:ff::e2.27713: . ack 19 win 267 <nop,nop,timestamp 1382884541 
1202052417> [flowlabel 0x23afd]
16:48:26.449705 MPLS(label 16, exp 0, ttl 254) CW(frag 0, sequence 0) 10.0.0.2 
> 10.0.0.1: icmp: echo request                         
16:48:26.450382 MPLS(label 121, exp 0, ttl 255) MPLS(label 16, exp 0, ttl 255) 
CW(frag 0, sequence 0) arp who-has 10.0.0.2 tell 10.0.0.1
16:48:26.451383 MPLS(label 16, exp 0, ttl 254) CW(frag 0, sequence 0) arp reply 
10.0.0.2 is-at fe:e1:bb:d1:01:8a
16:48:26.451764 MPLS(label 121, exp 0, ttl 255) MPLS(label 16, exp 0, ttl 255) 
CW(frag 0, sequence 0) 10.0.0.1 > 10.0.0.2: icmp: echo reply
16:48:27.457712 MPLS(label 16, exp 0, ttl 254) CW(frag 0, sequence 0) 10.0.0.2 
> 10.0.0.1: icmp: echo request
16:48:27.458318 MPLS(label 121, exp 0, ttl 255) MPLS(label 16, exp 0, ttl 255) 
CW(frag 0, sequence 0) 10.0.0.1 > 10.0.0.2: icmp: echo reply
16:48:28.442794 MPLS(label 16, exp 0, ttl 254) CW(frag 0, sequence 0) 10.0.0.2 
> 10.0.0.1: icmp: echo request
16:48:28.443388 MPLS(label 121, exp 0, ttl 255) MPLS(label 16, exp 0, ttl 255) 
CW(frag 0, sequence 0) 10.0.0.1 > 10.0.0.2: icmp: echo reply
---------------

Index: if_mpw.c
===================================================================
RCS file: /cvs/src/sys/net/if_mpw.c,v
retrieving revision 1.24
diff -u -p -r1.24 if_mpw.c
--- if_mpw.c    19 Feb 2018 08:59:52 -0000      1.24
+++ if_mpw.c    21 Dec 2018 20:18:45 -0000
@@ -149,6 +149,10 @@ mpw_ioctl(struct ifnet *ifp, u_long cmd,
        struct mpw_softc *sc = ifp->if_softc;
        struct sockaddr_in *sin;
        struct sockaddr_in *sin_nexthop;
+#ifdef INET6
+       struct sockaddr_in6 *sin6;
+       struct sockaddr_in6 *sin6_nexthop;
+#endif
        int error = 0;
        struct ifmpwreq imr;
 
@@ -177,23 +181,40 @@ mpw_ioctl(struct ifnet *ifp, u_long cmd,
                if (error != 0)
                        break;
 
-               /* Teardown all configuration if got no nexthop */
-               sin = (struct sockaddr_in *) &imr.imr_nexthop;
-               if (sin->sin_addr.s_addr == 0) {
+               switch (imr.imr_nexthop.ss_family) {
+#ifdef INET6
+               case AF_INET6:
+                       sin6 = (struct sockaddr_in6 *) &imr.imr_nexthop;
+                       memset(&sc->sc_nexthop, 0, sizeof(sc->sc_nexthop));
+                       sin6_nexthop = (struct sockaddr_in6 *) &sc->sc_nexthop;
+                       sin6_nexthop->sin6_family = sin6->sin6_family;
+                       sin6_nexthop->sin6_len = sizeof(struct sockaddr_in6);
+                       memcpy(&sin6_nexthop->sin6_addr, &sin6->sin6_addr,
+                           sizeof(struct in6_addr));
+                       break;
+#endif
+               case AF_INET:
+                       sin = (struct sockaddr_in *) &imr.imr_nexthop;
+                       memset(&sc->sc_nexthop, 0, sizeof(sc->sc_nexthop));
+                       sin_nexthop = (struct sockaddr_in *) &sc->sc_nexthop;
+                       sin_nexthop->sin_family = sin->sin_family;
+                       sin_nexthop->sin_len = sizeof(struct sockaddr_in);
+                       sin_nexthop->sin_addr.s_addr = sin->sin_addr.s_addr;
+                       break;
+               default:
+                       /* Teardown all configuration if got no nexthop */
                        if (rt_ifa_del(&sc->sc_ifa, RTF_MPLS,
                            smplstosa(&sc->sc_smpls)) == 0)
                                sc->sc_smpls.smpls_label = 0;
-
                        memset(&sc->sc_rshim, 0, sizeof(sc->sc_rshim));
                        memset(&sc->sc_nexthop, 0, sizeof(sc->sc_nexthop));
                        sc->sc_flags = 0;
                        sc->sc_type = 0;
-                       break;
+                       goto end;
                }
 
                /* Validate input */
-               if (sin->sin_family != AF_INET ||
-                   imr.imr_lshim.shim_label > MPLS_LABEL_MAX ||
+               if (imr.imr_lshim.shim_label > MPLS_LABEL_MAX ||
                    imr.imr_lshim.shim_label <= MPLS_LABEL_RESERVED_MAX ||
                    imr.imr_rshim.shim_label > MPLS_LABEL_MAX ||
                    imr.imr_rshim.shim_label <= MPLS_LABEL_RESERVED_MAX) {
@@ -227,11 +248,6 @@ mpw_ioctl(struct ifnet *ifp, u_long cmd,
                sc->sc_rshim.shim_label = imr.imr_rshim.shim_label;
                sc->sc_rshim.shim_label |= MPLS_BOS_MASK;
 
-               memset(&sc->sc_nexthop, 0, sizeof(sc->sc_nexthop));
-               sin_nexthop = (struct sockaddr_in *) &sc->sc_nexthop;
-               sin_nexthop->sin_family = sin->sin_family;
-               sin_nexthop->sin_len = sizeof(struct sockaddr_in);
-               sin_nexthop->sin_addr.s_addr = sin->sin_addr.s_addr;
                break;
 
        case SIOCGETMPWCFG:
@@ -253,7 +269,7 @@ mpw_ioctl(struct ifnet *ifp, u_long cmd,
                error = ENOTTY;
                break;
        }
-
+end:
        return (error);
 }
 

Reply via email to