]> git.proxmox.com Git - mirror_iproute2.git/blobdiff - ip/ipaddress.c
Merge branch 'master' into next
[mirror_iproute2.git] / ip / ipaddress.c
index 1309ac7ca58851f999b15e7b746971fc1450c6f4..bc8f5ba13c33a2b26469b8dd6b374e6101dd3e56 100644 (file)
@@ -26,6 +26,7 @@
 
 #include <linux/netdevice.h>
 #include <linux/if_arp.h>
+#include <linux/if_infiniband.h>
 #include <linux/sockios.h>
 #include <linux/net_namespace.h>
 
@@ -350,9 +351,10 @@ static void print_af_spec(FILE *fp, struct rtattr *af_spec_attr)
 
 static void print_vf_stats64(FILE *fp, struct rtattr *vfstats);
 
-static void print_vfinfo(FILE *fp, struct rtattr *vfinfo)
+static void print_vfinfo(FILE *fp, struct ifinfomsg *ifi, struct rtattr *vfinfo)
 {
        struct ifla_vf_mac *vf_mac;
+       struct ifla_vf_broadcast *vf_broadcast;
        struct ifla_vf_tx_rate *vf_tx_rate;
        struct rtattr *vf[IFLA_VF_MAX + 1] = {};
 
@@ -366,13 +368,41 @@ static void print_vfinfo(FILE *fp, struct rtattr *vfinfo)
        parse_rtattr_nested(vf, IFLA_VF_MAX, vfinfo);
 
        vf_mac = RTA_DATA(vf[IFLA_VF_MAC]);
+       vf_broadcast = RTA_DATA(vf[IFLA_VF_BROADCAST]);
        vf_tx_rate = RTA_DATA(vf[IFLA_VF_TX_RATE]);
 
        print_string(PRINT_FP, NULL, "%s    ", _SL_);
        print_int(PRINT_ANY, "vf", "vf %d ", vf_mac->vf);
-       print_string(PRINT_ANY, "mac", "MAC %s",
-                    ll_addr_n2a((unsigned char *) &vf_mac->mac,
-                                ETH_ALEN, 0, b1, sizeof(b1)));
+
+       print_string(PRINT_ANY,
+                    "link_type",
+                    "    link/%s ",
+                    ll_type_n2a(ifi->ifi_type, b1, sizeof(b1)));
+
+       print_color_string(PRINT_ANY, COLOR_MAC,
+                          "address", "%s",
+                          ll_addr_n2a((unsigned char *) &vf_mac->mac,
+                                      ifi->ifi_type == ARPHRD_ETHER ?
+                                      ETH_ALEN : INFINIBAND_ALEN,
+                                      ifi->ifi_type,
+                                      b1, sizeof(b1)));
+
+       if (vf[IFLA_VF_BROADCAST]) {
+               if (ifi->ifi_flags&IFF_POINTOPOINT) {
+                       print_string(PRINT_FP, NULL, " peer ", NULL);
+                       print_bool(PRINT_JSON,
+                                  "link_pointtopoint", NULL, true);
+               } else
+                       print_string(PRINT_FP, NULL, " brd ", NULL);
+
+               print_color_string(PRINT_ANY, COLOR_MAC,
+                                  "broadcast", "%s",
+                                  ll_addr_n2a((unsigned char *) &vf_broadcast->broadcast,
+                                              ifi->ifi_type == ARPHRD_ETHER ?
+                                              ETH_ALEN : INFINIBAND_ALEN,
+                                              ifi->ifi_type,
+                                              b1, sizeof(b1)));
+       }
 
        if (vf[IFLA_VF_VLAN_LIST]) {
                struct rtattr *i, *vfvlanlist = vf[IFLA_VF_VLAN_LIST];
@@ -1103,7 +1133,7 @@ int print_linkinfo(struct nlmsghdr *n, void *arg)
                open_json_array(PRINT_JSON, "vfinfo_list");
                for (i = RTA_DATA(vflist); RTA_OK(i, rem); i = RTA_NEXT(i, rem)) {
                        open_json_object(NULL);
-                       print_vfinfo(fp, i);
+                       print_vfinfo(fp, ifi, i);
                        close_json_object();
                }
                close_json_array(PRINT_JSON, NULL);
@@ -1851,7 +1881,6 @@ static int ipaddr_list_flush_or_save(int argc, char **argv, int action)
        ipaddr_reset_filter(oneline, 0);
        filter.showqueue = 1;
        filter.family = preferred_family;
-       filter.group = -1;
 
        if (action == IPADD_FLUSH) {
                if (argc <= 0) {
@@ -2108,6 +2137,7 @@ void ipaddr_reset_filter(int oneline, int ifindex)
        memset(&filter, 0, sizeof(filter));
        filter.oneline = oneline;
        filter.ifindex = ifindex;
+       filter.group = -1;
 }
 
 static int default_scope(inet_prefix *lcl)
@@ -2248,11 +2278,20 @@ static int ipaddr_modify(int cmd, int flags, int argc, char **argv)
                        if (set_lifetime(&preferred_lft, *argv))
                                invarg("preferred_lft value", *argv);
                } else if (strcmp(*argv, "home") == 0) {
-                       ifa_flags |= IFA_F_HOMEADDRESS;
+                       if (req.ifa.ifa_family == AF_INET6)
+                               ifa_flags |= IFA_F_HOMEADDRESS;
+                       else
+                               fprintf(stderr, "Warning: home option can be set only for IPv6 addresses\n");
                } else if (strcmp(*argv, "nodad") == 0) {
-                       ifa_flags |= IFA_F_NODAD;
+                       if (req.ifa.ifa_family == AF_INET6)
+                               ifa_flags |= IFA_F_NODAD;
+                       else
+                               fprintf(stderr, "Warning: nodad option can be set only for IPv6 addresses\n");
                } else if (strcmp(*argv, "mngtmpaddr") == 0) {
-                       ifa_flags |= IFA_F_MANAGETEMPADDR;
+                       if (req.ifa.ifa_family == AF_INET6)
+                               ifa_flags |= IFA_F_MANAGETEMPADDR;
+                       else
+                               fprintf(stderr, "Warning: mngtmpaddr option can be set only for IPv6 addresses\n");
                } else if (strcmp(*argv, "noprefixroute") == 0) {
                        ifa_flags |= IFA_F_NOPREFIXROUTE;
                } else if (strcmp(*argv, "autojoin") == 0) {