diff options
-rw-r--r-- | bridge/mdb.c | 51 | ||||
-rw-r--r-- | man/man8/bridge.8 | 15 |
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. |