]> git.proxmox.com Git - mirror_iproute2.git/blobdiff - bridge/fdb.c
iplink: Use ll_index_to_name() instead of if_indextoname()
[mirror_iproute2.git] / bridge / fdb.c
index e5cebf9ba69c1807bfc21578142b5b00f9af825d..4d55fb04b009a23165f4ffdbb8005bbee28f0f99 100644 (file)
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: GPL-2.0 */
 /*
  * Get/set/delete fdb table with netlink
  *
@@ -35,11 +36,12 @@ json_writer_t *jw_global;
 
 static void usage(void)
 {
-       fprintf(stderr, "Usage: bridge fdb { add | append | del | replace } ADDR dev DEV\n"
-                       "              [ self ] [ master ] [ use ] [ router ]\n"
-                       "              [ local | static | dynamic ] [ dst IPADDR ] [ vlan VID ]\n"
-                       "              [ port PORT] [ vni VNI ] [ via DEV ]\n");
-       fprintf(stderr, "       bridge fdb [ show [ br BRDEV ] [ brport DEV ] [ vlan VID ] [ state STATE ] ]\n");
+       fprintf(stderr,
+               "Usage: bridge fdb { add | append | del | replace } ADDR dev DEV\n"
+               "              [ self ] [ master ] [ use ] [ router ]\n"
+               "              [ local | static | dynamic ] [ dst IPADDR ] [ vlan VID ]\n"
+               "              [ port PORT] [ vni VNI ] [ via DEV ]\n"
+               "       bridge fdb [ show [ br BRDEV ] [ brport DEV ] [ vlan VID ] [ state STATE ] ]\n");
        exit(-1);
 }
 
@@ -204,14 +206,22 @@ int print_fdb(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
                                rta_getattr_u32(tb[NDA_VNI]));
        }
 
+       if (tb[NDA_SRC_VNI]) {
+               if (jw_global)
+                       jsonw_uint_field(jw_global, "src_vni",
+                                        rta_getattr_u32(tb[NDA_SRC_VNI]));
+               else
+                       fprintf(fp, "src_vni %d ",
+                               rta_getattr_u32(tb[NDA_SRC_VNI]));
+       }
+
        if (tb[NDA_IFINDEX]) {
                unsigned int ifindex = rta_getattr_u32(tb[NDA_IFINDEX]);
 
                if (ifindex) {
-                       char ifname[IF_NAMESIZE];
+                       if (!tb[NDA_LINK_NETNSID]) {
+                               const char *ifname = ll_index_to_name(ifindex);
 
-                       if (!tb[NDA_LINK_NETNSID] &&
-                           if_indextoname(ifindex, ifname)) {
                                if (jw_global)
                                        jsonw_string_field(jw_global, "viaIf",
                                                           ifname);
@@ -479,9 +489,9 @@ static int fdb_modify(int cmd, int flags, int argc, char **argv)
                } else if (matches(*argv, "use") == 0) {
                        req.ndm.ndm_flags |= NTF_USE;
                } else {
-                       if (strcmp(*argv, "to") == 0) {
+                       if (strcmp(*argv, "to") == 0)
                                NEXT_ARG();
-                       }
+
                        if (matches(*argv, "help") == 0)
                                usage();
                        if (addr)
@@ -535,7 +545,7 @@ static int fdb_modify(int cmd, int flags, int argc, char **argv)
                return -1;
        }
 
-       if (rtnl_talk(&rth, &req.n, NULL, 0) < 0)
+       if (rtnl_talk(&rth, &req.n, NULL) < 0)
                return -1;
 
        return 0;