lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20100210114708.14570.30921.stgit@localhost.localdomain>
Date:	Wed, 10 Feb 2010 03:47:08 -0800
From:	Jeff Kirsher <jeffrey.t.kirsher@...el.com>
To:	davem@...emloft.net, shemminger@...tta.com
Cc:	netdev@...r.kernel.org, gospo@...hat.com,
	Mitch Williams <mitch.a.williams@...el.com>,
	Jeff Kirsher <jeffrey.t.kirsher@...el.com>
Subject: [iproute2 PATCH v2 3/4] ip: Add support for setting and showing
	SR-IOV virtual funtion link params

From: Williams, Mitch A <mitch.a.williams@...el.com>

Add support to 'ip' for setting and showing SR-IOV virtual function
link parameters.

Signed-off-by: Mitch Williams <mitch.a.williams@...el.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@...el.com>
---

 ip/ipaddress.c |   25 +++++++++++++++++++++++++
 ip/iplink.c    |   52 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 77 insertions(+), 0 deletions(-)

diff --git a/ip/ipaddress.c b/ip/ipaddress.c
index e9256d9..3186f9c 100644
--- a/ip/ipaddress.c
+++ b/ip/ipaddress.c
@@ -331,6 +331,31 @@ int print_linkinfo(const struct sockaddr_nl *who,
 				);
 		}
 	}
+	if (do_link && tb[IFLA_VFINFO] && tb[IFLA_NUM_VF]) {
+		SPRINT_BUF(b1);
+		struct rtattr *rta = tb[IFLA_VFINFO];
+		struct ifla_vf_info *ivi;
+		int i;
+		for (i = 0; i < *(int *)RTA_DATA(tb[IFLA_NUM_VF]); i++) {
+			if (rta->rta_type != IFLA_VFINFO) {
+				fprintf(stderr, "BUG: rta type is %d\n", rta->rta_type);
+				break;
+			}
+			ivi = RTA_DATA(rta);
+			fprintf(fp, "\n    vf %d: MAC %s",
+				ivi->vf,
+				ll_addr_n2a((unsigned char *)&ivi->mac,
+					    ETH_ALEN, 0, b1, sizeof(b1)));
+				if (ivi->vlan)
+					fprintf(fp, ", vlan %d", ivi->vlan);
+				if (ivi->qos)
+					fprintf(fp, ", qos %d", ivi->qos);
+				if (ivi->tx_rate)
+					fprintf(fp, ", tx rate %d (Mbps_",
+						ivi->tx_rate);
+			rta = (struct rtattr *)((char *)rta + RTA_ALIGN(rta->rta_len));
+		}
+	}
 	fprintf(fp, "\n");
 	fflush(fp);
 	return 0;
diff --git a/ip/iplink.c b/ip/iplink.c
index 32cce24..97fca8b 100644
--- a/ip/iplink.c
+++ b/ip/iplink.c
@@ -68,6 +68,9 @@ void iplink_usage(void)
 	fprintf(stderr, "	                  [ mtu MTU ]\n");
 	fprintf(stderr, "	                  [ netns PID ]\n");
 	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, "       ip link show [ DEVICE ]\n");
 
 	if (iplink_have_newlink()) {
@@ -181,6 +184,7 @@ int iplink_parse(int argc, char **argv, struct iplink_req *req,
 	int qlen = -1;
 	int mtu = -1;
 	int netns = -1;
+	int vf = -1;
 
 	ret = argc;
 
@@ -278,6 +282,54 @@ int iplink_parse(int argc, char **argv, struct iplink_req *req,
 				req->i.ifi_flags |= IFF_NOARP;
 			} else
 				return on_off("noarp");
+		} else if (strcmp(*argv, "vf") == 0) {
+			NEXT_ARG();
+			if (get_integer(&vf,  *argv, 0)) {
+				invarg("Invalid \"vf\" value\n", *argv);
+			}
+		} else if (matches(*argv, "mac") == 0) {
+			struct ifla_vf_mac ivm;
+			NEXT_ARG();
+			if (vf < 0) {
+				missarg("vf");
+			}
+			ivm.vf = vf;
+			len = ll_addr_a2n((char *)ivm.mac, 32, *argv);
+			if (len < 0)
+				return -1;
+			addattr_l(&req->n, sizeof(*req), IFLA_VF_MAC, &ivm, sizeof(ivm));
+		} else if (matches(*argv, "vlan") == 0) {
+			struct ifla_vf_vlan ivv;
+			NEXT_ARG();
+			if (vf < 0) {
+				missarg("vf");
+			}
+			if (get_unsigned(&ivv.vlan, *argv, 0)) {
+				invarg("Invalid \"vlan\" value\n", *argv);
+			}
+			ivv.vf = vf;
+			ivv.qos = 0;
+			if (NEXT_ARG_OK()) {
+				NEXT_ARG();
+				if (matches(*argv, "qos") == 0) {
+					NEXT_ARG();
+					if (get_unsigned(&ivv.qos, *argv, 0)) {
+						invarg("Invalid \"qos\" value\n", *argv);
+					}
+				}
+			}
+			addattr_l(&req->n, sizeof(*req), IFLA_VF_VLAN, &ivv, sizeof(ivv));
+		} else if (matches(*argv, "rate") == 0) {
+			struct ifla_vf_tx_rate ivt;
+			NEXT_ARG();
+			if (vf < 0) {
+				missarg("vf");
+			}
+			if (get_unsigned(&ivt.rate, *argv, 0)) {
+				invarg("Invalid \"rate\" value\n", *argv);
+			}
+			ivt.vf = vf;
+			addattr_l(&req->n, sizeof(*req), IFLA_VF_TX_RATE, &ivt, sizeof(ivt));
 #ifdef IFF_DYNAMIC
 		} else if (matches(*argv, "dynamic") == 0) {
 			NEXT_ARG();

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ