source address selection logic.
These hacks were only relevant for the NFS diskless boot code in order to
pick the local broadcast address of the only configured interface. So, be
explicit and set this address directly.
Tested by florian@, ok henning@, beck@, chrisz@
-/* $OpenBSD: in_pcb.c,v 1.154 2014/04/18 10:48:29 jca Exp $ */
+/* $OpenBSD: in_pcb.c,v 1.155 2014/05/07 08:26:38 mpi Exp $ */
/* $NetBSD: in_pcb.c,v 1.25 1996/02/13 23:41:53 christos Exp $ */
/*
return in6_pcbbind(inp, nam, p);
#endif /* INET6 */
- if (TAILQ_EMPTY(&in_ifaddr))
- return (EADDRNOTAVAIL);
if (inp->inp_lport || inp->inp_laddr.s_addr != INADDR_ANY)
return (EINVAL);
if ((so->so_options & (SO_REUSEADDR|SO_REUSEPORT)) == 0 &&
struct sockaddr_in *sin2;
struct in_ifaddr *ia = NULL;
- if (!TAILQ_EMPTY(&in_ifaddr)) {
- if (sin->sin_addr.s_addr == INADDR_ANY)
- sin->sin_addr =
- TAILQ_FIRST(&in_ifaddr)->ia_addr.sin_addr;
- else if (sin->sin_addr.s_addr == INADDR_BROADCAST &&
- (TAILQ_FIRST(&in_ifaddr)->ia_ifp->if_flags & IFF_BROADCAST) &&
- TAILQ_FIRST(&in_ifaddr)->ia_broadaddr.sin_addr.s_addr)
- sin->sin_addr =
- TAILQ_FIRST(&in_ifaddr)->ia_broadaddr.sin_addr;
- }
-
/*
* If the source address is not specified but the socket(if any)
* is already bound, use the bound address.
*/
if (ro->ro_rt && ro->ro_rt->rt_ifp)
ia = ifatoia(ro->ro_rt->rt_ifa);
- if (ia == NULL) {
- ia = TAILQ_FIRST(&in_ifaddr);
- if (ia == NULL)
- return (EADDRNOTAVAIL);
- }
+
+ if (ia == NULL)
+ return (EADDRNOTAVAIL);
*insrc = &ia->ia_addr.sin_addr;
return (0);
-/* $OpenBSD: ip_input.c,v 1.231 2014/04/21 12:22:26 henning Exp $ */
+/* $OpenBSD: ip_input.c,v 1.232 2014/05/07 08:26:38 mpi Exp $ */
/* $NetBSD: ip_input.c,v 1.30 1996/03/16 23:53:58 christos Exp $ */
/*
ifp = m->m_pkthdr.rcvif;
- /*
- * If no IP addresses have been set yet but the interfaces
- * are receiving, can't do anything with incoming packets yet.
- */
- if (TAILQ_EMPTY(&in_ifaddr))
- goto bad;
ipstat.ips_total++;
if (m->m_len < sizeof (struct ip) &&
(m = m_pullup(m, sizeof (struct ip))) == NULL) {
-/* $OpenBSD: nfs_boot.c,v 1.31 2014/03/20 09:18:01 mpi Exp $ */
+/* $OpenBSD: nfs_boot.c,v 1.32 2014/05/07 08:26:38 mpi Exp $ */
/* $NetBSD: nfs_boot.c,v 1.26 1996/05/07 02:51:25 thorpej Exp $ */
/*
struct sockaddr_in *sin;
struct ifnet *ifp;
struct socket *so;
+ struct ifaddr *ifa;
char addr[INET_ADDRSTRLEN];
int error;
soclose(so);
+ TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) {
+ if (ifa->ifa_addr->sa_family == AF_INET)
+ break;
+ }
+ if (ifa == NULL)
+ panic("nfs_boot: address not configured on %s", ifp->if_xname);
+
/*
* Get client name and gateway address.
* RPC: bootparam/whoami
- * Use the old broadcast address for the WHOAMI
- * call because we do not yet know our netmask.
* The server address returned by the WHOAMI call
* is used for all subsequent bootparam RPCs.
*/
bzero((caddr_t)&bp_sin, sizeof(bp_sin));
bp_sin.sin_len = sizeof(bp_sin);
bp_sin.sin_family = AF_INET;
- bp_sin.sin_addr.s_addr = INADDR_BROADCAST;
+ bp_sin.sin_addr.s_addr = ifatoia(ifa)->ia_broadaddr.sin_addr.s_addr;
hostnamelen = MAXHOSTNAMELEN;
/* this returns gateway IP address */