Blame SOURCES/iproute2-3.10.0-Add-VF-link-state-control.patch

7787e2
diff --git a/ip/ipaddress.c b/ip/ipaddress.c
7787e2
index 2b3707a..013b4cb 100644
7787e2
--- a/ip/ipaddress.c
7787e2
+++ b/ip/ipaddress.c
7787e2
@@ -229,6 +229,7 @@ static void print_vfinfo(FILE *fp, struct rtattr *vfinfo)
7787e2
 	struct ifla_vf_vlan *vf_vlan;
7787e2
 	struct ifla_vf_tx_rate *vf_tx_rate;
7787e2
 	struct ifla_vf_spoofchk *vf_spoofchk;
7787e2
+	struct ifla_vf_link_state *vf_linkstate;
7787e2
 	struct rtattr *vf[IFLA_VF_MAX+1];
7787e2
 	struct rtattr *tmp;
7787e2
 	SPRINT_BUF(b1);
7787e2
@@ -255,6 +256,20 @@ static void print_vfinfo(FILE *fp, struct rtattr *vfinfo)
7787e2
 	else
7787e2
 		vf_spoofchk = RTA_DATA(vf[IFLA_VF_SPOOFCHK]);
7787e2
 
7787e2
+	if (vf_spoofchk) {
7787e2
+		/* Check if the link state vf info type is supported by
7787e2
+		 * this kernel.
7787e2
+		 */
7787e2
+		tmp = (struct rtattr *)((char *)vf[IFLA_VF_SPOOFCHK] +
7787e2
+				vf[IFLA_VF_SPOOFCHK]->rta_len);
7787e2
+
7787e2
+		if (tmp->rta_type != IFLA_VF_LINK_STATE)
7787e2
+			vf_linkstate = NULL;
7787e2
+		else
7787e2
+			vf_linkstate = RTA_DATA(vf[IFLA_VF_LINK_STATE]);
7787e2
+	} else
7787e2
+		vf_linkstate = NULL;
7787e2
+
7787e2
 	fprintf(fp, "\n    vf %d MAC %s", vf_mac->vf,
7787e2
 		ll_addr_n2a((unsigned char *)&vf_mac->mac,
7787e2
 		ETH_ALEN, 0, b1, sizeof(b1)));
7787e2
@@ -270,6 +285,14 @@ static void print_vfinfo(FILE *fp, struct rtattr *vfinfo)
7787e2
 		else
7787e2
 			fprintf(fp, ", spoof checking off");
7787e2
 	}
7787e2
+	if (vf_linkstate) {
7787e2
+		if (vf_linkstate->link_state == IFLA_VF_LINK_STATE_AUTO)
7787e2
+			fprintf(fp, ", link-state auto");
7787e2
+		else if (vf_linkstate->link_state == IFLA_VF_LINK_STATE_ENABLE)
7787e2
+			fprintf(fp, ", link-state enable");
7787e2
+		else
7787e2
+			fprintf(fp, ", link-state disable");
7787e2
+	}
7787e2
 }
7787e2
 
7787e2
 static void print_link_stats64(FILE *fp, const struct rtnl_link_stats64 *s) {
7787e2
diff --git a/ip/iplink.c b/ip/iplink.c
7787e2
index 15dd84f..f8bcd8c 100644
7787e2
--- a/ip/iplink.c
7787e2
+++ b/ip/iplink.c
7787e2
@@ -77,6 +77,7 @@ void iplink_usage(void)
7787e2
 	fprintf(stderr, "				   [ rate TXRATE ] ] \n");
7787e2
 
7787e2
 	fprintf(stderr, "				   [ spoofchk { on | off} ] ] \n");
7787e2
+	fprintf(stderr, "				   [ state { auto | enable | disable} ] ]\n");
7787e2
 	fprintf(stderr, "			  [ master DEVICE ]\n");
7787e2
 	fprintf(stderr, "			  [ nomaster ]\n");
7787e2
 	fprintf(stderr, "       ip link show [ DEVICE | group GROUP ] [up]\n");
7787e2
@@ -260,6 +261,19 @@ static int iplink_parse_vf(int vf, int *argcp, char ***argvp,
7787e2
 			ivs.vf = vf;
7787e2
 			addattr_l(&req->n, sizeof(*req), IFLA_VF_SPOOFCHK, &ivs, sizeof(ivs));
7787e2
 
7787e2
+		} else if (matches(*argv, "state") == 0) {
7787e2
+			struct ifla_vf_link_state ivl;
7787e2
+			NEXT_ARG();
7787e2
+			if (matches(*argv, "auto") == 0)
7787e2
+				ivl.link_state = IFLA_VF_LINK_STATE_AUTO;
7787e2
+			else if (matches(*argv, "enable") == 0)
7787e2
+				ivl.link_state = IFLA_VF_LINK_STATE_ENABLE;
7787e2
+			else if (matches(*argv, "disable") == 0)
7787e2
+				ivl.link_state = IFLA_VF_LINK_STATE_DISABLE;
7787e2
+			else
7787e2
+				invarg("Invalid \"state\" value\n", *argv);
7787e2
+			ivl.vf = vf;
7787e2
+			addattr_l(&req->n, sizeof(*req), IFLA_VF_LINK_STATE, &ivl, sizeof(ivl));
7787e2
 		} else {
7787e2
 			/* rewind arg */
7787e2
 			PREV_ARG();
7787e2
diff --git a/include/linux/if_link.h b/include/linux/if_link.h
7787e2
index 9a31d6b..20092a7 100644
7787e2
--- a/include/linux/if_link.h
7787e2
+++ b/include/linux/if_link.h
7787e2
@@ -362,6 +362,18 @@ struct ifla_vf_spoofchk {
7787e2
 	__u32 setting;
7787e2
 };
7787e2
 
7787e2
+enum {
7787e2
+	IFLA_VF_LINK_STATE_AUTO,        /* link state of the uplink */
7787e2
+	IFLA_VF_LINK_STATE_ENABLE,      /* link always up */
7787e2
+	IFLA_VF_LINK_STATE_DISABLE,     /* link always down */
7787e2
+	__IFLA_VF_LINK_STATE_MAX,
7787e2
+};
7787e2
+
7787e2
+struct ifla_vf_link_state {
7787e2
+	__u32 vf;
7787e2
+	__u32 link_state;
7787e2
+};
7787e2
+
7787e2
 /* VF ports management section
7787e2
  *
7787e2
  *	Nested layout of set/get msg is:
7787e2
diff --git a/include/linux/if_link.h b/include/linux/if_link.h
7787e2
index 20092a7..4877906 100644
7787e2
--- a/include/linux/if_link.h
7787e2
+++ b/include/linux/if_link.h
7787e2
@@ -336,6 +336,7 @@ enum {
7787e2
 	IFLA_VF_VLAN,
7787e2
 	IFLA_VF_TX_RATE,	/* TX Bandwidth Allocation */
7787e2
 	IFLA_VF_SPOOFCHK,	/* Spoof Checking on/off switch */
7787e2
+	IFLA_VF_LINK_STATE,     /* link state enable/disable/auto switch */
7787e2
 	__IFLA_VF_MAX,
7787e2
 };
7787e2