From: Denis Fondras Subject: ifconfig: add and document vxlan "[-]endpoint" command To: tech@openbsd.org Date: Sun, 5 Jan 2025 13:41:21 +0100 This diff adds a command to remove an endpoint when vxlan(4) is in endpoint mode. Also add some documentation for the "endpoint" command. Change is not 100% satisfaying as the "endpoint" and "-endpoint" does not take the same number of arguments. Any opinion ? Index: brconfig.c =================================================================== RCS file: /cvs/src/sbin/ifconfig/brconfig.c,v diff -u -p -r1.32 brconfig.c --- brconfig.c 23 Nov 2023 03:38:34 -0000 1.32 +++ brconfig.c 5 Jan 2025 12:33:53 -0000 @@ -693,6 +693,29 @@ bridge_addendpoint(const char *endpoint, } void +bridge_delendpoint(const char *addr, int d) +{ + struct ifbareq ifba; + struct ether_addr *ea; + int ecode; + + ea = ether_aton(addr); + if (ea == NULL) { + errx(1, "%s -endpoint %s: invalid Ethernet address", + ifname, addr); + } + + memset(&ifba, 0, sizeof(ifba)); + strlcpy(ifba.ifba_name, ifname, sizeof(ifba.ifba_name)); + strlcpy(ifba.ifba_ifsname, ifname, sizeof(ifba.ifba_ifsname)); + memcpy(&ifba.ifba_dst, ea, sizeof(struct ether_addr)); + ifba.ifba_flags = IFBAF_STATIC; + + if (ioctl(sock, SIOCBRDGDADDR, &ifba) == -1) + err(1, "%s -endpoint %s", ifname, addr); +} + +void bridge_addrs(const char *delim, int d) { char dstaddr[NI_MAXHOST]; Index: ifconfig.8 =================================================================== RCS file: /cvs/src/sbin/ifconfig/ifconfig.8,v diff -u -p -r1.400 ifconfig.8 --- ifconfig.8 9 Jun 2024 16:25:27 -0000 1.400 +++ ifconfig.8 5 Jan 2025 12:33:53 -0000 @@ -1841,6 +1841,7 @@ for a complete list of the available pro .Bk -words .Nm ifconfig .Ar tunnel-interface +.Op Oo Fl Oc Ns Cm endpoint Ar dest_address dest_mac .Op Oo Fl Oc Ns Cm keepalive Ar period count .Op Oo Fl Oc Ns Cm parent Ar parent-interface .Op Cm rxprio Ar prio @@ -1867,6 +1868,20 @@ and are all tunnel interfaces. The following options are available: .Bl -tag -width Ds +.It Cm endpoint Ar dest_address dest_mac +When +.Xr vxlan 4 +is in endpoint mode, set the tunnel endpoint +.Ar dest_address +where +.Ar dest_mac +MAC address can be reached. +.It Cm -endpoint Ar dest_mac +When +.Xr vxlan 4 +is in endpoint mode, remove the tunnel endpoint for +.Ar dest_mac +MAC address. .It Cm keepalive Ar period count Enable .Xr gre 4 Index: ifconfig.c =================================================================== RCS file: /cvs/src/sbin/ifconfig/ifconfig.c,v diff -u -p -r1.474 ifconfig.c --- ifconfig.c 29 Jun 2024 12:09:51 -0000 1.474 +++ ifconfig.c 5 Jan 2025 12:33:53 -0000 @@ -578,6 +578,7 @@ const struct cmd { { "flushall", 0, 0, bridge_flushall }, { "static", NEXTARG2, 0, NULL, bridge_addaddr }, { "endpoint", NEXTARG2, 0, NULL, bridge_addendpoint }, + { "-endpoint", NEXTARG, 0, bridge_delendpoint }, { "deladdr", NEXTARG, 0, bridge_deladdr }, { "maxaddr", NEXTARG, 0, bridge_maxaddr }, { "addr", 0, 0, bridge_addrs }, @@ -624,7 +625,7 @@ const struct cmd { { "wgpeer", NEXTARG, A_WIREGUARD, setwgpeer}, { "wgdescription", NEXTARG, A_WIREGUARD, setwgpeerdesc}, { "wgdescr", NEXTARG, A_WIREGUARD, setwgpeerdesc}, - { "wgendpoint", NEXTARG2, A_WIREGUARD, NULL, setwgpeerep}, + { "wgendpoint", NEXTARG2, A_WIREGUARD, NULL, setwgpeerep}, { "wgaip", NEXTARG, A_WIREGUARD, setwgpeeraip}, { "wgpsk", NEXTARG, A_WIREGUARD, setwgpeerpsk}, { "wgpka", NEXTARG, A_WIREGUARD, setwgpeerpka}, Index: ifconfig.h =================================================================== RCS file: /cvs/src/sbin/ifconfig/ifconfig.h,v diff -u -p -r1.5 ifconfig.h --- ifconfig.h 23 Nov 2023 03:38:34 -0000 1.5 +++ ifconfig.h 5 Jan 2025 12:33:53 -0000 @@ -49,6 +49,7 @@ void bridge_flush(const char *, int); void bridge_flushall(const char *, int); void bridge_addaddr(const char *, const char *); void bridge_addendpoint(const char *, const char *); +void bridge_delendpoint(const char *, int); void bridge_deladdr(const char *, int); void bridge_maxaddr(const char *, int); void bridge_addrs(const char *, int);