summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIdo Schimmel <idosch@nvidia.com>2023-03-21 15:01:22 +0200
committerDavid Ahern <dsahern@kernel.org>2023-03-24 18:29:14 -0600
commitd36899c2244ccf61cf74180fc644d50f9230e773 (patch)
tree473d7fc6d0daecd8358a98ba057d9c6bc0a2a9e5
parentd0d5eeff798c1ab84c7e13d5d75a3c336dfcdb49 (diff)
downloadiproute2-d36899c2244ccf61cf74180fc644d50f9230e773.tar.gz
bridge: mdb: Add underlay destination IP support
Allow user space to program and view VXLAN MDB entries. Specifically, add support for the 'MDBE_ATTR_DST' and 'MDBA_MDB_EATTR_DST' attributes in request and response messages, respectively. The attributes encode the IP address of the destination VXLAN tunnel endpoint where multicast receivers for the specified multicast flow reside. Multiple destinations can be added for each flow. Example: # bridge mdb add dev vxlan0 port vxlan0 grp 239.1.1.1 permanent dst 198.51.100.1 # bridge mdb add dev vxlan0 port vxlan0 grp 239.1.1.1 permanent dst 192.0.2.1 $ bridge -d -s mdb show dev vxlan0 port vxlan0 grp 239.1.1.1 permanent filter_mode exclude proto static dst 192.0.2.1 0.00 dev vxlan0 port vxlan0 grp 239.1.1.1 permanent filter_mode exclude proto static dst 198.51.100.1 0.00 $ bridge -d -s -j -p mdb show [ { "mdb": [ { "index": 15, "dev": "vxlan0", "port": "vxlan0", "grp": "239.1.1.1", "state": "permanent", "filter_mode": "exclude", "protocol": "static", "flags": [ ], "dst": "192.0.2.1", "timer": " 0.00" },{ "index": 15, "dev": "vxlan0", "port": "vxlan0", "grp": "239.1.1.1", "state": "permanent", "filter_mode": "exclude", "protocol": "static", "flags": [ ], "dst": "198.51.100.1", "timer": " 0.00" } ], "router": {} } ] Signed-off-by: Ido Schimmel <idosch@nvidia.com> Reviewed-by: Nikolay Aleksandrov <razor@blackwall.org>
-rw-r--r--bridge/mdb.c51
-rw-r--r--man/man8/bridge.815
2 files changed, 63 insertions, 3 deletions
diff --git a/bridge/mdb.c b/bridge/mdb.c
index 9b550365..137d509c 100644
--- a/bridge/mdb.c
+++ b/bridge/mdb.c
@@ -32,7 +32,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 ]\n"
+ " [ filter_mode { include | exclude } ] [ source_list SOURCE_LIST ] [ proto PROTO ] [ dst IPADDR ]\n"
" bridge mdb {show} [ dev DEV ] [ vid VID ]\n");
exit(-1);
}
@@ -146,6 +146,21 @@ static void print_src_entry(struct rtattr *src_attr, int af, const char *sep)
close_json_object();
}
+static void print_dst(const struct rtattr *dst_attr)
+{
+ SPRINT_BUF(abuf);
+ int af = AF_INET;
+ const void *dst;
+
+ if (RTA_PAYLOAD(dst_attr) == sizeof(struct in6_addr))
+ af = AF_INET6;
+
+ dst = (const void *)RTA_DATA(dst_attr);
+ print_color_string(PRINT_ANY, ifa_family_color(af),
+ "dst", " dst %s",
+ inet_ntop(af, dst, abuf, sizeof(abuf)));
+}
+
static void print_mdb_entry(FILE *f, int ifindex, const struct br_mdb_entry *e,
struct nlmsghdr *n, struct rtattr **tb)
{
@@ -240,6 +255,9 @@ static void print_mdb_entry(FILE *f, int ifindex, const struct br_mdb_entry *e,
if (e->vid)
print_uint(PRINT_ANY, "vid", " vid %u", e->vid);
+ if (tb[MDBA_MDB_EATTR_DST])
+ print_dst(tb[MDBA_MDB_EATTR_DST]);
+
if (show_stats && tb && tb[MDBA_MDB_EATTR_TIMER]) {
__u32 timer = rta_getattr_u32(tb[MDBA_MDB_EATTR_TIMER]);
@@ -570,6 +588,25 @@ static int mdb_parse_proto(struct nlmsghdr *n, int maxlen, const char *proto)
return 0;
}
+static int mdb_parse_dst(struct nlmsghdr *n, int maxlen, const char *dst)
+{
+ struct in6_addr dst_ip6;
+ __be32 dst_ip4;
+
+ if (inet_pton(AF_INET, dst, &dst_ip4)) {
+ addattr32(n, maxlen, MDBE_ATTR_DST, dst_ip4);
+ return 0;
+ }
+
+ if (inet_pton(AF_INET6, dst, &dst_ip6)) {
+ addattr_l(n, maxlen, MDBE_ATTR_DST, &dst_ip6,
+ sizeof(dst_ip6));
+ return 0;
+ }
+
+ return -1;
+}
+
static int mdb_modify(int cmd, int flags, int argc, char **argv)
{
struct {
@@ -583,7 +620,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 *src_list = NULL, *proto = NULL;
+ char *src_list = NULL, *proto = NULL, *dst = NULL;
struct br_mdb_entry entry = {};
bool set_attrs = false;
short vid = 0;
@@ -622,6 +659,10 @@ static int mdb_modify(int cmd, int flags, int argc, char **argv)
NEXT_ARG();
proto = *argv;
set_attrs = true;
+ } else if (strcmp(*argv, "dst") == 0) {
+ NEXT_ARG();
+ dst = *argv;
+ set_attrs = true;
} else {
if (matches(*argv, "help") == 0)
usage();
@@ -675,6 +716,12 @@ static int mdb_modify(int cmd, int flags, int argc, char **argv)
return -1;
}
+ if (dst && mdb_parse_dst(&req.n, sizeof(req), dst)) {
+ fprintf(stderr, "Invalid underlay destination address \"%s\"\n",
+ dst);
+ return -1;
+ }
+
addattr_nest_end(&req.n, nest);
}
diff --git a/man/man8/bridge.8 b/man/man8/bridge.8
index abc0417b..2f8500af 100644
--- a/man/man8/bridge.8
+++ b/man/man8/bridge.8
@@ -145,7 +145,9 @@ bridge \- show / manipulate bridge addresses and devices
.B source_list
.IR SOURCE_LIST " ] [ "
.B proto
-.IR PROTO " ]
+.IR PROTO " ] [ "
+.B dst
+.IR IPADDR " ]
.ti -8
.BR "bridge mdb show" " [ "
@@ -970,6 +972,17 @@ then
is assumed.
.in -8
+The next command line parameters apply only
+when the specified device
+.I DEV
+is of type VXLAN.
+
+.TP
+.BI dst " IPADDR"
+the IP address of the destination
+VXLAN tunnel endpoint where the multicast receivers reside.
+
+.in -8
.SS bridge mdb delete - delete a multicast group database entry
This command removes an existing mdb entry.