[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1397737053-11892-5-git-send-email-jiri@resnulli.us>
Date: Thu, 17 Apr 2014 14:17:32 +0200
From: Jiri Pirko <jiri@...nulli.us>
To: netdev@...r.kernel.org
Cc: davem@...emloft.net, nhorman@...driver.com, andy@...yhouse.net,
tgraf@...g.ch, dborkman@...hat.com, ogerlitz@...lanox.com,
jesse@...ira.com, pshelar@...ira.com, azhou@...ira.com,
ben@...adent.org.uk, stephen@...workplumber.org,
jeffrey.t.kirsher@...el.com, vyasevic@...hat.com,
xiyou.wangcong@...il.com, john.r.fastabend@...el.com,
edumazet@...gle.com, jhs@...atatu.com, sfeldma@...ulusnetworks.com,
f.fainelli@...il.com, roopa@...ulusnetworks.com,
linville@...driver.com, dev@...nvswitch.org, jasowang@...hat.com,
ebiederm@...ssion.com, nicolas.dichtel@...nd.com,
ryazanov.s.a@...il.com, buytenh@...tstofly.org,
aviadr@...lanox.com, nbd@...nwrt.org, alexei.starovoitov@...il.com,
Neil.Jerram@...aswitch.com
Subject: [patch iproute2 RFC v3 4/5] iproute2: add support for dummyswport
Signed-off-by: Jiri Pirko <jiri@...nulli.us>
---
include/linux/if_link.h | 9 ++++++++
ip/Makefile | 3 ++-
ip/iplink_dummyswport.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 67 insertions(+), 1 deletion(-)
create mode 100644 ip/iplink_dummyswport.c
diff --git a/include/linux/if_link.h b/include/linux/if_link.h
index 2932453..f2fdb85 100644
--- a/include/linux/if_link.h
+++ b/include/linux/if_link.h
@@ -544,4 +544,13 @@ enum {
#define IFLA_HSR_MAX (__IFLA_HSR_MAX - 1)
+/* DUMMYSWPORT section */
+enum {
+ IFLA_DUMMYSWPORT_UNSPEC,
+ IFLA_DYMMYSWPORT_PHYS_SWITCH_ID,
+ __IFLA_DUMMYSWPORT_MAX,
+};
+
+#define IFLA_DUMMYSWPORT_MAX (__IFLA_DUMMYSWPORT_MAX - 1)
+
#endif /* _LINUX_IF_LINK_H */
diff --git a/ip/Makefile b/ip/Makefile
index 713adf5..35546e5 100644
--- a/ip/Makefile
+++ b/ip/Makefile
@@ -5,7 +5,8 @@ IPOBJ=ip.o ipaddress.o ipaddrlabel.o iproute.o iprule.o ipnetns.o \
iplink_vlan.o link_veth.o link_gre.o iplink_can.o \
iplink_macvlan.o iplink_macvtap.o ipl2tp.o link_vti.o \
iplink_vxlan.o tcp_metrics.o iplink_ipoib.o ipnetconf.o link_ip6tnl.o \
- link_iptnl.o link_gre6.o iplink_bond.o iplink_bond_slave.o iplink_hsr.o
+ link_iptnl.o link_gre6.o iplink_bond.o iplink_bond_slave.o iplink_hsr.o \
+ iplink_dummyswport.o \
RTMONOBJ=rtmon.o
diff --git a/ip/iplink_dummyswport.c b/ip/iplink_dummyswport.c
new file mode 100644
index 0000000..64f1a02
--- /dev/null
+++ b/ip/iplink_dummyswport.c
@@ -0,0 +1,56 @@
+/*
+ * iplink_dummyswport.c dummy switch port device support
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ *
+ * Authors: Jiri Pirko <jiri@...nulli.us>
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/socket.h>
+#include <sys/types.h>
+#include <asm/types.h>
+#include <linux/if_link.h>
+#include <net/if.h>
+
+#include "rt_names.h"
+#include "utils.h"
+#include "ip_common.h"
+
+static void explain(void)
+{
+ fprintf(stderr, "Usage: ... dummyswport swid SWITCH_ID\n");
+}
+
+static int dummyswport_parse_opt(struct link_util *lu, int argc, char **argv,
+ struct nlmsghdr *n)
+{
+ while (argc > 0) {
+ if (matches(*argv, "swid") == 0) {
+ __u8 buf[32];
+
+ NEXT_ARG();
+ if (!hexstring_a2n(*argv, buf, sizeof(buf)))
+ invarg("invalid \"swid\" value\n", *argv);
+ addattr_l(n, 1024, IFLA_DYMMYSWPORT_PHYS_SWITCH_ID,
+ buf, strlen(*argv) / 2);
+ } else {
+ fprintf(stderr, "dummyswport: unknown option \"%s\"?\n", *argv);
+ explain();
+ return -1;
+ }
+ argc--, argv++;
+ }
+ return 0;
+}
+
+struct link_util dummyswport_link_util = {
+ .id = "dummyswport",
+ .maxattr = IFLA_DUMMYSWPORT_MAX,
+ .parse_opt = dummyswport_parse_opt,
+};
--
1.9.0
--
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