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  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:	Wed, 4 Jul 2012 00:18:12 +0000
From:	Arvid Brodin <Arvid.Brodin@...n.com>
To:	"netdev@...r.kernel.org" <netdev@...r.kernel.org>
CC:	Stephen Hemminger <shemminger@...tta.com>,
	Alexey Kuznetsov <kuznet@....inr.ac.ru>,
	Javier Boticario <jboticario@...il.com>,
	Bruno Ferreira <balferreira@...glemail.com>
Subject: [RFC v2 2/2] net/hsr: Add support for IEC 62439-3 High-availability
 Seamless Redundancy

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@...a.com>
+ *
+ * 		Based on iplink_vlan.c by Patrick McHardy <kaber@...sh.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

Powered by blists - more mailing lists