Module Name: src Committed By: rtr Date: Sat Apr 25 15:19:54 UTC 2015
Modified Files: src/sys/netinet: raw_ip.c Log Message: make rip_connect_pcb take sockaddr_in * instead of mbuf * make rip_connect_pcb static since it appears to be used only in raw_ip.c moves m_len check to callers which is a small duplication of code that will go away when the callers are converted to receive sockaddr *. To generate a diff of this commit: cvs rdiff -u -r1.148 -r1.149 src/sys/netinet/raw_ip.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/netinet/raw_ip.c diff -u src/sys/netinet/raw_ip.c:1.148 src/sys/netinet/raw_ip.c:1.149 --- src/sys/netinet/raw_ip.c:1.148 Fri Apr 24 22:32:37 2015 +++ src/sys/netinet/raw_ip.c Sat Apr 25 15:19:54 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: raw_ip.c,v 1.148 2015/04/24 22:32:37 rtr Exp $ */ +/* $NetBSD: raw_ip.c,v 1.149 2015/04/25 15:19:54 rtr Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -65,7 +65,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: raw_ip.c,v 1.148 2015/04/24 22:32:37 rtr Exp $"); +__KERNEL_RCSID(0, "$NetBSD: raw_ip.c,v 1.149 2015/04/25 15:19:54 rtr Exp $"); #include "opt_inet.h" #include "opt_compat_netbsd.h" @@ -111,7 +111,7 @@ struct inpcbtable rawcbtable; int rip_pcbnotify(struct inpcbtable *, struct in_addr, struct in_addr, int, int, void (*)(struct inpcb *, int)); -int rip_connect_pcb(struct inpcb *, struct mbuf *); +static int rip_connect_pcb(struct inpcb *, struct sockaddr_in *); static void rip_disconnect1(struct inpcb *); static void sysctl_net_inet_raw_setup(struct sysctllog **); @@ -480,12 +480,9 @@ rip_ctloutput(int op, struct socket *so, } int -rip_connect_pcb(struct inpcb *inp, struct mbuf *nam) +rip_connect_pcb(struct inpcb *inp, struct sockaddr_in *addr) { - struct sockaddr_in *addr = mtod(nam, struct sockaddr_in *); - if (nam->m_len != sizeof(*addr)) - return (EINVAL); if (IFNET_EMPTY()) return (EADDRNOTAVAIL); if (addr->sin_family != AF_INET) @@ -612,7 +609,9 @@ rip_connect(struct socket *so, struct mb KASSERT(nam != NULL); s = splsoftnet(); - error = rip_connect_pcb(inp, nam); + if (nam->m_len != sizeof(struct sockaddr_in)) + return EINVAL; + error = rip_connect_pcb(inp, mtod(nam, struct sockaddr_in *)); if (! error) soisconnected(so); splx(s); @@ -763,7 +762,9 @@ rip_send(struct socket *so, struct mbuf error = EISCONN; goto die; } - error = rip_connect_pcb(inp, nam); + if (nam->m_len != sizeof(struct sockaddr_in)) + return EINVAL; + error = rip_connect_pcb(inp, mtod(nam, struct sockaddr_in *)); if (error) { die: m_freem(m);