summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIdo Schimmel <idosch@nvidia.com>2023-03-21 15:01:26 +0200
committerDavid Ahern <dsahern@kernel.org>2023-03-24 18:29:50 -0600
commita3f4565e0a643f03815904768556e53f2544ccbd (patch)
treea691e7908b853e0aebe1d4c216c1ff14ebafa078
parent9e49c798540c34e3df6d75e6871f4f69c1bb4e15 (diff)
downloadiproute2-a3f4565e0a643f03815904768556e53f2544ccbd.tar.gz
bridge: mdb: Add outgoing interface support
In a similar fashion to VXLAN FDB entries, allow user space to program and view the outgoing interface of VXLAN MDB entries. Specifically, add support for the 'MDBE_ATTR_IFINDEX' and 'MDBA_MDB_EATTR_IFINDEX' attributes in request and response messages, respectively. The outgoing interface will be forced during the underlay route lookup and is required when the underlay destination IP is multicast, as the multicast routing tables are not consulted. Example: # bridge mdb add dev vxlan0 port vxlan0 grp 239.1.1.1 permanent dst 198.51.100.1 via dummy10 $ bridge -d -s mdb show dev vxlan0 port vxlan0 grp 239.1.1.1 permanent filter_mode exclude proto static dst 198.51.100.1 via dummy10 0.00 $ bridge -d -s -j -p mdb show [ { "mdb": [ { "index": 10, "dev": "vxlan0", "port": "vxlan0", "grp": "239.1.1.1", "state": "permanent", "filter_mode": "exclude", "protocol": "static", "flags": [ ], "dst": "198.51.100.1", "via": "dummy10", "timer": " 0.00" } ], "router": {} } ] Signed-off-by: Ido Schimmel <idosch@nvidia.com> Reviewed-by: Nikolay Aleksandrov <razor@blackwall.org>
-rw-r--r--bridge/mdb.c32
-rw-r--r--man/man8/bridge.89
2 files changed, 38 insertions, 3 deletions
diff --git a/bridge/mdb.c b/bridge/mdb.c
index ee83aa38..dcc08235 100644
--- a/bridge/mdb.c
+++ b/bridge/mdb.c
@@ -34,7 +34,7 @@ static void usage(void)
fprintf(stderr,
"Usage: bridge mdb { add | del | replace } dev DEV port PORT grp GROUP [src SOURCE] [permanent | temp] [vid VID]\n"
" [ filter_mode { include | exclude } ] [ source_list SOURCE_LIST ] [ proto PROTO ] [ dst IPADDR ]\n"
- " [ dst_port DST_PORT ] [ vni VNI ] [ src_vni SRC_VNI ]\n"
+ " [ dst_port DST_PORT ] [ vni VNI ] [ src_vni SRC_VNI ] [ via DEV ]\n"
" bridge mdb {show} [ dev DEV ] [ vid VID ]\n");
exit(-1);
}
@@ -272,6 +272,14 @@ static void print_mdb_entry(FILE *f, int ifindex, const struct br_mdb_entry *e,
print_uint(PRINT_ANY, "src_vni", " src_vni %u",
rta_getattr_u32(tb[MDBA_MDB_EATTR_SRC_VNI]));
+ if (tb[MDBA_MDB_EATTR_IFINDEX]) {
+ unsigned int ifindex;
+
+ ifindex = rta_getattr_u32(tb[MDBA_MDB_EATTR_IFINDEX]);
+ print_string(PRINT_ANY, "via", " via %s",
+ ll_index_to_name(ifindex));
+ }
+
if (show_stats && tb && tb[MDBA_MDB_EATTR_TIMER]) {
__u32 timer = rta_getattr_u32(tb[MDBA_MDB_EATTR_TIMER]);
@@ -659,6 +667,19 @@ static int mdb_parse_vni(struct nlmsghdr *n, int maxlen, const char *vni,
return 0;
}
+static int mdb_parse_dev(struct nlmsghdr *n, int maxlen, const char *dev)
+{
+ unsigned int ifindex;
+
+ ifindex = ll_name_to_index(dev);
+ if (!ifindex)
+ return -1;
+
+ addattr32(n, maxlen, MDBE_ATTR_IFINDEX, ifindex);
+
+ return 0;
+}
+
static int mdb_modify(int cmd, int flags, int argc, char **argv)
{
struct {
@@ -672,7 +693,7 @@ static int mdb_modify(int cmd, int flags, int argc, char **argv)
.bpm.family = PF_BRIDGE,
};
char *d = NULL, *p = NULL, *grp = NULL, *src = NULL, *mode = NULL;
- char *dst_port = NULL, *vni = NULL, *src_vni = NULL;
+ char *dst_port = NULL, *vni = NULL, *src_vni = NULL, *via = NULL;
char *src_list = NULL, *proto = NULL, *dst = NULL;
struct br_mdb_entry entry = {};
bool set_attrs = false;
@@ -728,6 +749,10 @@ static int mdb_modify(int cmd, int flags, int argc, char **argv)
NEXT_ARG();
src_vni = *argv;
set_attrs = true;
+ } else if (strcmp(*argv, "via") == 0) {
+ NEXT_ARG();
+ via = *argv;
+ set_attrs = true;
} else {
if (matches(*argv, "help") == 0)
usage();
@@ -806,6 +831,9 @@ static int mdb_modify(int cmd, int flags, int argc, char **argv)
return -1;
}
+ if (via && mdb_parse_dev(&req.n, sizeof(req), via))
+ return nodev(via);
+
addattr_nest_end(&req.n, nest);
}
diff --git a/man/man8/bridge.8 b/man/man8/bridge.8
index 88046dc1..9753ce9e 100644
--- a/man/man8/bridge.8
+++ b/man/man8/bridge.8
@@ -153,7 +153,9 @@ bridge \- show / manipulate bridge addresses and devices
.B vni
.IR VNI " ] [ "
.B src_vni
-.IR SRC_VNI " ]
+.IR SRC_VNI " ] [ "
+.B via
+.IR DEV " ]
.ti -8
.BR "bridge mdb show" " [ "
@@ -1006,6 +1008,11 @@ the source VNI Network Identifier this entry belongs to. Used only when the
VXLAN device is in external mode. If omitted, the value specified at VXLAN
device creation will be used.
+.TP
+.BI via " DEV"
+device name of the outgoing interface for the VXLAN device to reach the remote
+VXLAN tunnel endpoint.
+
.in -8
.SS bridge mdb delete - delete a multicast group database entry
This command removes an existing mdb entry.