From: Arvid Brodin <Arvid.Brodin@xdin.com>
To: "netdev@vger.kernel.org" <netdev@vger.kernel.org>
Cc: Stephen Hemminger <shemminger@vyatta.com>,
Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>,
Javier Boticario <jboticario@gmail.com>,
Bruno Ferreira <balferreira@googlemail.com>
Subject: [RFC v2 2/2] net/hsr: Add support for IEC 62439-3 High-availability Seamless Redundancy
Date: Wed, 4 Jul 2012 00:18:12 +0000 [thread overview]
Message-ID: <4FF38BC4.9090901@xdin.com> (raw)
The iproute patch.
Syntax:
# ip link add name hsr0 type hsr eth0 eth1
# ip link del dev hsr0
diff -Nurp iproute2-2.6.35-orig/ip/Makefile iproute2-2.6.35-hsr/ip/Makefile
--- iproute2-2.6.35-orig/ip/Makefile 2010-08-04 19:45:59.000000000 +0200
+++ iproute2-2.6.35-hsr/ip/Makefile 2011-12-13 19:43:14.271913247 +0100
@@ -3,7 +3,7 @@ IPOBJ=ip.o ipaddress.o ipaddrlabel.o ipr
ipmaddr.o ipmonitor.o ipmroute.o ipprefix.o iptuntap.o \
ipxfrm.o xfrm_state.o xfrm_policy.o xfrm_monitor.o \
iplink_vlan.o link_veth.o link_gre.o iplink_can.o \
- iplink_macvlan.o
+ iplink_macvlan.o iplink_hsr.o
RTMONOBJ=rtmon.o
diff -Nurp iproute2-2.6.35-orig/ip/iplink_hsr.c iproute2-2.6.35-hsr/ip/iplink_hsr.c
--- iproute2-2.6.35-orig/ip/iplink_hsr.c 1970-01-01 01:00:00.000000000 +0100
+++ iproute2-2.6.35-hsr/ip/iplink_hsr.c 2011-12-13 19:43:14.252913043 +0100
@@ -0,0 +1,101 @@
+/*
+ * iplink_hsr.c HSR 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: Arvid Brodin <arvid.brodin@enea.com>
+ *
+ * Based on iplink_vlan.c by Patrick McHardy <kaber@trash.net>
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/socket.h> /* Needed by linux/if.h for some reason */
+#include <linux/if.h>
+#include <linux/if_vlan.h>
+
+#include "rt_names.h"
+#include "utils.h"
+#include "ip_common.h"
+
+static void explain(void)
+{
+ fprintf(stderr,
+ "Usage: ip link add name NAME type hsr SLAVE1 SLAVE2\n"
+ "\n"
+ "NAME name of new hsr device (e.g. hsr0)\n"
+ "SLAVE1, SLAVE2 the two slave devices bound by hsr0\n"
+ );
+}
+
+static int hsr_parse_opt(struct link_util *lu, int argc, char **argv,
+ struct nlmsghdr *n)
+{
+ char *name, *link;
+ int ifindex, len;
+
+ if (argc != 2) {
+ explain();
+ return -1;
+ }
+
+ switch (n->nlmsg_type) {
+ case RTM_NEWLINK:
+ if (argc != 2) {
+ explain();
+ return -1;
+ }
+ while (argc > 0) {
+ link = *argv;
+ ifindex = ll_name_to_index(link);
+ if (argc == 2)
+ addattr_l(n, 1024, IFLA_HSR_SLAVE1, &ifindex, 4);
+ else
+ addattr_l(n, 1024, IFLA_HSR_SLAVE2, &ifindex, 4);
+ printf("Slave %d: %s; %d\n", 3-argc, link, ifindex);
+ argc--;
+ argv++;
+ }
+ break;
+
+ case RTM_DELLINK:
+ if (argc != 0) {
+ explain();
+ return -1;
+ }
+ break;
+
+ default:
+ return -1;
+ }
+
+ return 0;
+
+/*
+ if (ifindex != 0) {
+ fprintf(stderr, "Link device \"%s\" already exist\n", name);
+ return -1;
+ }
+ if (ifindex == 0) {
+ fprintf(stderr, "Cannot find device \"%s\"\n",
+ link);
+ return -1;
+ }
+*/
+}
+
+static void hsr_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
+{
+ fprintf(f, "hsr_print_opt() called\n");
+}
+
+struct link_util hsr_link_util = {
+ .id = "hsr",
+ .maxattr = IFLA_VLAN_MAX,
+ .parse_opt = hsr_parse_opt,
+ .print_opt = hsr_print_opt,
+};
--- iproute2-2.6.35-orig/ip/iplink.c 2010-08-04 19:45:59.000000000 +0200
+++ iproute2-2.6.35-build/ip/iplink.c 2011-12-07 00:12:09.588604817 +0100
@@ -433,6 +433,6 @@ static int iplink_modify(int cmd, unsign
lu = get_link_kind(type);
- if (lu && argc) {
+ if (lu) {
struct rtattr * data = NLMSG_TAIL(&req.n);
addattr_l(&req.n, sizeof(req), IFLA_INFO_DATA, NULL, 0);
--- iproute2-2.6.35-orig/include/linux/if_link.h 2010-08-04 19:45:59.000000000 +0200
+++ iproute2-2.6.35-hsr/include/linux/if_link.h 2011-12-13 19:51:22.639129004 +0100
@@ -347,4 +347,15 @@ struct ifla_port_vsi {
__u8 pad[3];
};
+/* HSR section */
+
+enum {
+ IFLA_HSR_UNSPEC,
+ IFLA_HSR_SLAVE1,
+ IFLA_HSR_SLAVE2,
+ __IFLA_HSR_MAX,
+};
+
+#define IFLA_HSR_MAX (__IFLA_HSR_MAX - 1)
+
#endif /* _LINUX_IF_LINK_H */
--
Arvid Brodin | Consultant (Linux)
XDIN AB | Jan Stenbecks Torg 17 | SE-164 40 Kista | Sweden | xdin.com
reply other threads:[~2012-07-04 0:18 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4FF38BC4.9090901@xdin.com \
--to=arvid.brodin@xdin.com \
--cc=balferreira@googlemail.com \
--cc=jboticario@gmail.com \
--cc=kuznet@ms2.inr.ac.ru \
--cc=netdev@vger.kernel.org \
--cc=shemminger@vyatta.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.