aboutsummaryrefslogtreecommitdiff
path: root/sys/netinet/ip_input.c
diff options
context:
space:
mode:
authorJulian Elischer <julian@FreeBSD.org>1997-11-05 02:51:32 +0000
committerJulian Elischer <julian@FreeBSD.org>1997-11-05 02:51:32 +0000
commitd314ad7b73639f51ca493f272c2ea5fe3f08dd87 (patch)
tree146526ea91cae550d865a64b8c6fcc34a99bc602 /sys/netinet/ip_input.c
parent6f81c4a889abc7f6b5a0af398fb8bbe1a8fc402e (diff)
downloadsrc-d314ad7b73639f51ca493f272c2ea5fe3f08dd87.tar.gz
src-d314ad7b73639f51ca493f272c2ea5fe3f08dd87.zip
Return the entire if info, rather than just the index number. (at least try)
Interface index numbers are an abomination that should go away (at least in that form)
Notes
Notes: svn path=/head/; revision=30948
Diffstat (limited to 'sys/netinet/ip_input.c')
-rw-r--r--sys/netinet/ip_input.c40
1 files changed, 31 insertions, 9 deletions
diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c
index ee4108313056..3929e4d847a6 100644
--- a/sys/netinet/ip_input.c
+++ b/sys/netinet/ip_input.c
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)ip_input.c 8.2 (Berkeley) 1/4/94
- * $Id: ip_input.c,v 1.68 1997/10/28 15:58:47 bde Exp $
+ * $Id: ip_input.c,v 1.69 1997/10/28 18:55:21 guido Exp $
* $ANA: ip_input.c,v 1.5 1996/09/18 14:34:59 wollman Exp $
*/
@@ -53,6 +53,7 @@
#include <sys/sysctl.h>
#include <net/if.h>
+#include <net/if_var.h>
#include <net/if_dl.h>
#include <net/route.h>
#include <net/netisr.h>
@@ -1443,14 +1444,35 @@ ip_savecontrol(inp, mp, ip, m)
}
#endif
if (inp->inp_flags & INP_RECVIF) {
- struct sockaddr_dl sdl;
-
- sdl.sdl_len = offsetof(struct sockaddr_dl, sdl_data[0]);
- sdl.sdl_family = AF_LINK;
- sdl.sdl_index = m->m_pkthdr.rcvif ?
- m->m_pkthdr.rcvif->if_index : 0;
- sdl.sdl_nlen = sdl.sdl_alen = sdl.sdl_slen = 0;
- *mp = sbcreatecontrol((caddr_t) &sdl, sdl.sdl_len,
+ struct ifnet *ifp;
+ struct sdlbuf {
+ struct sockaddr_dl sdl;
+ u_char pad[32];
+ } sdlbuf;
+ struct sockaddr_dl *sdp;
+ struct sockaddr_dl *sdl2 = &sdlbuf.sdl;
+
+ if (((ifp = m->m_pkthdr.rcvif))
+ && ( ifp->if_index && (ifp->if_index <= if_index))) {
+ sdp = (struct sockaddr_dl *)(ifnet_addrs
+ [ifp->if_index - 1]->ifa_addr);
+ /*
+ * Change our mind and don't try copy.
+ */
+ if ((sdp->sdl_family != AF_LINK)
+ || (sdp->sdl_len > sizeof(sdlbuf))) {
+ goto makedummy;
+ }
+ bcopy(sdp, sdl2, sdp->sdl_len);
+ } else {
+makedummy:
+ sdl2->sdl_len
+ = offsetof(struct sockaddr_dl, sdl_data[0]);
+ sdl2->sdl_family = AF_LINK;
+ sdl2->sdl_index = 0;
+ sdl2->sdl_nlen = sdl2->sdl_alen = sdl2->sdl_slen = 0;
+ }
+ *mp = sbcreatecontrol((caddr_t) sdl2, sdl2->sdl_len,
IP_RECVIF, IPPROTO_IP);
if (*mp)
mp = &(*mp)->m_next;