Module Name:    src
Committed By:   christos
Date:           Wed Apr  6 17:34:33 UTC 2016

Modified Files:
        src/sys/net: rtsock.c

Log Message:
Don't interpret routing requests by interface index as arp entry additions!


To generate a diff of this commit:
cvs rdiff -u -r1.179 -r1.180 src/sys/net/rtsock.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/net/rtsock.c
diff -u src/sys/net/rtsock.c:1.179 src/sys/net/rtsock.c:1.180
--- src/sys/net/rtsock.c:1.179	Tue Apr  5 06:03:33 2016
+++ src/sys/net/rtsock.c	Wed Apr  6 13:34:33 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: rtsock.c,v 1.179 2016/04/05 10:03:33 ozaki-r Exp $	*/
+/*	$NetBSD: rtsock.c,v 1.180 2016/04/06 17:34:33 christos Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -61,7 +61,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rtsock.c,v 1.179 2016/04/05 10:03:33 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rtsock.c,v 1.180 2016/04/06 17:34:33 christos Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -568,13 +568,18 @@ COMPATNAME(route_output)(struct mbuf *m,
 #ifdef INET
 		/* support for new ARP code with keeping backcompat */
 		if (info.rti_info[RTAX_GATEWAY]->sa_family == AF_LINK) {
-			int sdl_index =
-			    satocsdl(info.rti_info[RTAX_GATEWAY])->sdl_index;
+			const struct sockaddr_dl *sdlp =
+			    satocsdl(info.rti_info[RTAX_GATEWAY]);
 
+			/* Allow routing requests by interface index */
+			if (sdlp->sdl_nlen == 0 && sdlp->sdl_alen == 0
+			    && sdlp->sdl_slen == 0)
+				goto fallback;
 			/*
 			 * Old arp binaries don't set the sdl_index
 			 * so we have to complement it.
 			 */
+			int sdl_index = sdlp->sdl_index;
 			if (sdl_index == 0) {
 				error = route_get_sdl_index(&info, &sdl_index);
 				if (error != 0)

Reply via email to