mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Matthias Andree <matthias.andree@stud.uni-dortmund.de>
To: Linux-Kernel mailing list <linux-kernel@vger.kernel.org>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>,
	"David S. Miller" <davem@redhat.com>,
	"netdev@oss.sgi.com" <netdev@oss.sgi.com>,
	Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>,
	ak@muc.de
Subject: 2.2.19 backport of devinet.c 4.4BSD compatibility patch to ioctl SIOCGIF*
Date: Tue, 2 Oct 2001 05:06:52 +0200	[thread overview]
Message-ID: <20011002050652.A30832@emma1.emma.line.org> (raw)
In-Reply-To: <20011001121931.B15943@emma1.emma.line.org>
In-Reply-To: <20011001121931.B15943@emma1.emma.line.org>

Here's that 2.4.9 patch to devinet.c backported to 2.2.19. Same
functionality, but caters for CONFIG_IP_ALIAS:

The patch is also available at
http://mandree.home.pages.de/linux/kernel/2.2/

Alan, please consider this for inclusion into your current 2.2.20pre*
series.

--- devinet.c.orig	Fri Dec 22 12:36:33 2000
+++ devinet.c	Tue Oct  2 04:29:03 2001
@@ -20,6 +20,10 @@
  *	Changes:
  *	        Alexey Kuznetsov:	pa_* fields are replaced with ifaddr lists.
  *		Cyrus Durgin:		updated for kmod
+ *		Matthias Andree:	in devinet_ioctl, compare label and 
+ *					address (4.4BSD alias style support),
+ *					fall back to comparing just the label
+ *					if no match found.
  */
 
 #include <linux/config.h>
@@ -405,6 +409,8 @@
 	struct device *dev;
 #ifdef CONFIG_IP_ALIAS
 	char *colon;
+	struct sockaddr_in sin_orig;
+	int tryaddrmatch = 0;
 #endif
 	int exclusive = 0;
 	int ret = 0;
@@ -418,6 +424,9 @@
 	ifr.ifr_name[IFNAMSIZ-1] = 0;
 
 #ifdef CONFIG_IP_ALIAS
+        /* save original address for comparison */
+ 	memcpy(&sin_orig, sin, sizeof(*sin));
+	
 	colon = strchr(ifr.ifr_name, ':');
 	if (colon)
 		*colon = 0;
@@ -436,6 +445,9 @@
 		   so that we do not impose a lock.
 		   One day we will be forced to put shlock here (I mean SMP)
 		 */
+#ifdef CONFIG_IP_ALIAS
+		tryaddrmatch = (sin_orig.sin_family == AF_INET);
+#endif
 		memset(sin, 0, sizeof(*sin));
 		sin->sin_family = AF_INET;
 		break;
@@ -473,6 +485,25 @@
 #endif
 
 	if ((in_dev=dev->ip_ptr) != NULL) {
+#ifdef CONFIG_IP_ALIAS
+		if (tryaddrmatch) {
+			/* Matthias Andree */
+			/* compare label and address (4.4BSD style) */
+			/* note: we only do this for a limited set of ioctls
+			   and only if the original address family was AF_INET.
+			   This is checked above. */
+			for (ifap=&in_dev->ifa_list; (ifa=*ifap) != NULL; ifap=&ifa->ifa_next) {
+				if ((strcmp(ifr.ifr_name, ifa->ifa_label) == 0)
+				    && (sin_orig.sin_addr.s_addr == ifa->ifa_address)) {
+					break; /* found */
+				} /* if */
+			} /* for */
+		}
+		/* we didn't get a match, maybe the application is
+		   4.3BSD-style and passed in junk so we fall back to 
+		   comparing just the label */
+		if (ifa == NULL) 
+#endif
 		for (ifap=&in_dev->ifa_list; (ifa=*ifap) != NULL; ifap=&ifa->ifa_next)
 			if (strcmp(ifr.ifr_name, ifa->ifa_label) == 0)
 				break;

-- 
Matthias Andree

      parent reply	other threads:[~2001-10-02 10:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-10-01 10:19 devinet.c 4.4BSD compatibility patch to ioctl SIOCGIF* for 2.4.10 Matthias Andree
2001-10-01 19:30 ` David S. Miller
2001-10-02  3:06 ` Matthias Andree [this message]

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=20011002050652.A30832@emma1.emma.line.org \
    --to=matthias.andree@stud.uni-dortmund.de \
    --cc=ak@muc.de \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=davem@redhat.com \
    --cc=kuznet@ms2.inr.ac.ru \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@oss.sgi.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®