diff --git a/ip/ipaddress.c b/ip/ipaddress.c index 85f05a24..2f2cabdf 100644 --- a/ip/ipaddress.c +++ b/ip/ipaddress.c @@ -197,7 +197,9 @@ static void print_vfinfo(FILE *fp, struct rtattr *vfinfo) struct ifla_vf_mac *vf_mac; struct ifla_vf_vlan *vf_vlan; struct ifla_vf_tx_rate *vf_tx_rate; + struct ifla_vf_spoofchk *vf_spoofchk; struct rtattr *vf[IFLA_VF_MAX+1]; + struct rtattr *tmp; SPRINT_BUF(b1); if (vfinfo->rta_type != IFLA_VF_INFO) { @@ -211,6 +213,17 @@ static void print_vfinfo(FILE *fp, struct rtattr *vfinfo) vf_vlan = RTA_DATA(vf[IFLA_VF_VLAN]); vf_tx_rate = RTA_DATA(vf[IFLA_VF_TX_RATE]); + /* Check if the spoof checking vf info type is supported by + * this kernel. + */ + tmp = (struct rtattr *)((char *)vf[IFLA_VF_TX_RATE] + + vf[IFLA_VF_TX_RATE]->rta_len); + + if (tmp->rta_type != IFLA_VF_SPOOFCHK) + vf_spoofchk = NULL; + else + vf_spoofchk = RTA_DATA(vf[IFLA_VF_SPOOFCHK]); + fprintf(fp, "\n vf %d MAC %s", vf_mac->vf, ll_addr_n2a((unsigned char *)&vf_mac->mac, ETH_ALEN, 0, b1, sizeof(b1))); @@ -220,6 +233,12 @@ static void print_vfinfo(FILE *fp, struct rtattr *vfinfo) fprintf(fp, ", qos %d", vf_vlan->qos); if (vf_tx_rate->rate) fprintf(fp, ", tx rate %d (Mbps)", vf_tx_rate->rate); + if (vf_spoofchk && vf_spoofchk->setting != -1) { + if (vf_spoofchk->setting) + fprintf(fp, ", spoof checking on"); + else + fprintf(fp, ", spoof checking off"); + } } int print_linkinfo(const struct sockaddr_nl *who, diff --git a/ip/iplink.c b/ip/iplink.c index 35e6dc6f..ca1aaebe 100644 --- a/ip/iplink.c +++ b/ip/iplink.c @@ -71,7 +71,10 @@ void iplink_usage(void) fprintf(stderr, " [ alias NAME ]\n"); fprintf(stderr, " [ vf NUM [ mac LLADDR ]\n"); fprintf(stderr, " [ vlan VLANID [ qos VLAN-QOS ] ]\n"); + fprintf(stderr, " [ rate TXRATE ] ] \n"); + + fprintf(stderr, " [ spoofchk { on | off} ] ] \n"); fprintf(stderr, " [ master DEVICE ]\n"); fprintf(stderr, " [ nomaster ]\n"); fprintf(stderr, " ip link show [ DEVICE | group GROUP ]\n"); @@ -228,6 +231,18 @@ int iplink_parse_vf(int vf, int *argcp, char ***argvp, ivt.vf = vf; addattr_l(&req->n, sizeof(*req), IFLA_VF_TX_RATE, &ivt, sizeof(ivt)); + } else if (matches(*argv, "spoofchk") == 0) { + struct ifla_vf_spoofchk ivs; + NEXT_ARG(); + if (matches(*argv, "on") == 0) + ivs.setting = 1; + else if (matches(*argv, "off") == 0) + ivs.setting = 0; + else + invarg("Invalid \"spoofchk\" value\n", *argv); + ivs.vf = vf; + addattr_l(&req->n, sizeof(*req), IFLA_VF_SPOOFCHK, &ivs, sizeof(ivs)); + } else { /* rewind arg */ PREV_ARG(); diff --git a/man/man8/ip.8 b/man/man8/ip.8 index 36431b6d..a20eca7b 100644 --- a/man/man8/ip.8 +++ b/man/man8/ip.8 @@ -100,7 +100,9 @@ ip \- show / manipulate routing, devices, policy routing and tunnels .B qos .IR VLAN-QOS " ] ] [" .B rate -.IR TXRATE " ] |" +.IR TXRATE " ] [" +.B spoofchk { on | off } +] | .br .B master .IR DEVICE