Commit fd08839c authored by Vlad Yasevich's avatar Vlad Yasevich Committed by Stephen Hemminger

bridge: Add vlan support to fdb entries

Provide the ability to set and show vlans on FDB entries.
Signed-off-by: default avatarVlad Yasevich <vyasevic@redhat.com>
parent c6ff4b83
...@@ -29,7 +29,7 @@ int filter_index; ...@@ -29,7 +29,7 @@ int filter_index;
static void usage(void) static void usage(void)
{ {
fprintf(stderr, "Usage: bridge fdb { add | del } ADDR dev DEV {self|master} [ temp ] [ dst IPADDR]\n"); fprintf(stderr, "Usage: bridge fdb { add | del } ADDR dev DEV {self|master} [ temp ] [ dst IPADDR] [ vlan VID ]\n");
fprintf(stderr, " bridge fdb {show} [ dev DEV ]\n"); fprintf(stderr, " bridge fdb {show} [ dev DEV ]\n");
exit(-1); exit(-1);
} }
...@@ -107,6 +107,11 @@ int print_fdb(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg) ...@@ -107,6 +107,11 @@ int print_fdb(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
abuf, sizeof(abuf))); abuf, sizeof(abuf)));
} }
if (tb[NDA_VLAN]) {
__u16 vid = rta_getattr_u16(tb[NDA_VLAN]);
fprintf(fp, "vlan %hu ", vid);
}
if (show_stats && tb[NDA_CACHEINFO]) { if (show_stats && tb[NDA_CACHEINFO]) {
struct nda_cacheinfo *ci = RTA_DATA(tb[NDA_CACHEINFO]); struct nda_cacheinfo *ci = RTA_DATA(tb[NDA_CACHEINFO]);
int hz = get_user_hz(); int hz = get_user_hz();
...@@ -171,6 +176,7 @@ static int fdb_modify(int cmd, int flags, int argc, char **argv) ...@@ -171,6 +176,7 @@ static int fdb_modify(int cmd, int flags, int argc, char **argv)
char abuf[ETH_ALEN]; char abuf[ETH_ALEN];
int dst_ok = 0; int dst_ok = 0;
inet_prefix dst; inet_prefix dst;
short vid = -1;
memset(&req, 0, sizeof(req)); memset(&req, 0, sizeof(req));
...@@ -199,6 +205,11 @@ static int fdb_modify(int cmd, int flags, int argc, char **argv) ...@@ -199,6 +205,11 @@ static int fdb_modify(int cmd, int flags, int argc, char **argv)
req.ndm.ndm_state |= NUD_PERMANENT; req.ndm.ndm_state |= NUD_PERMANENT;
} else if (matches(*argv, "temp") == 0) { } else if (matches(*argv, "temp") == 0) {
req.ndm.ndm_state |= NUD_REACHABLE; req.ndm.ndm_state |= NUD_REACHABLE;
} else if (matches(*argv, "vlan") == 0) {
if (vid >= 0)
duparg2("vlan", *argv);
NEXT_ARG();
vid = atoi(*argv);
} else { } else {
if (strcmp(*argv, "to") == 0) { if (strcmp(*argv, "to") == 0) {
NEXT_ARG(); NEXT_ARG();
...@@ -236,6 +247,9 @@ static int fdb_modify(int cmd, int flags, int argc, char **argv) ...@@ -236,6 +247,9 @@ static int fdb_modify(int cmd, int flags, int argc, char **argv)
if (dst_ok) if (dst_ok)
addattr_l(&req.n, sizeof(req), NDA_DST, &dst.data, dst.bytelen); addattr_l(&req.n, sizeof(req), NDA_DST, &dst.data, dst.bytelen);
if (vid >= 0)
addattr16(&req.n, sizeof(req), NDA_VLAN, vid);
req.ndm.ndm_ifindex = ll_name_to_index(d); req.ndm.ndm_ifindex = ll_name_to_index(d);
if (req.ndm.ndm_ifindex == 0) { if (req.ndm.ndm_ifindex == 0) {
fprintf(stderr, "Cannot find device \"%s\"\n", d); fprintf(stderr, "Cannot find device \"%s\"\n", d);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment