Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Use if_addr_init() and if_mcast_op() instead of ifp->if_...
details: https://anonhg.NetBSD.org/src/rev/a7fe0f6d2b45
branches: trunk
changeset: 770502:a7fe0f6d2b45
user: dyoung <dyoung%NetBSD.org@localhost>
date: Wed Oct 19 01:52:22 2011 +0000
description:
Use if_addr_init() and if_mcast_op() instead of ifp->if_ioctl().
diffstat:
sys/netinet/in.c | 16 ++++++----------
sys/netinet/ip_carp.c | 20 +++++---------------
sys/netinet/ip_mroute.c | 12 ++++--------
sys/netinet6/in6.c | 8 ++++----
sys/netinet6/ip6_mroute.c | 29 +++++++++++++++--------------
sys/netinet6/mld6.c | 16 ++++++++--------
sys/netiso/iso.c | 6 +++---
sys/netiso/iso_snpac.c | 14 +++++++-------
8 files changed, 52 insertions(+), 69 deletions(-)
diffs (truncated from 429 to 300 lines):
diff -r 5a87bd9464e4 -r a7fe0f6d2b45 sys/netinet/in.c
--- a/sys/netinet/in.c Wed Oct 19 01:50:27 2011 +0000
+++ b/sys/netinet/in.c Wed Oct 19 01:52:22 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: in.c,v 1.138 2010/05/15 05:02:46 oki Exp $ */
+/* $NetBSD: in.c,v 1.139 2011/10/19 01:52:22 dyoung Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -91,7 +91,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: in.c,v 1.138 2010/05/15 05:02:46 oki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in.c,v 1.139 2011/10/19 01:52:22 dyoung Exp $");
#include "opt_inet.h"
#include "opt_inet_conf.h"
@@ -454,7 +454,7 @@
return (EINVAL);
oldaddr = ia->ia_dstaddr;
ia->ia_dstaddr = *satocsin(ifreq_getdstaddr(cmd, ifr));
- if ((error = (*ifp->if_ioctl)(ifp, SIOCSIFDSTADDR, ia)) != 0) {
+ if ((error = if_addr_init(ifp, &ia->ia_ifa, false)) != 0) {
ia->ia_dstaddr = oldaddr;
return error;
}
@@ -813,7 +813,7 @@
* if this is its first address,
* and to validate the address if necessary.
*/
- if ((error = (*ifp->if_ioctl)(ifp, SIOCINITIFADDR, ia)) != 0)
+ if ((error = if_addr_init(ifp, &ia->ia_ifa, true)) != 0)
goto bad;
splx(s);
if (scrub) {
@@ -1045,7 +1045,6 @@
{
struct sockaddr_in sin;
struct in_multi *inm;
- struct ifreq ifr;
int s = splsoftnet();
/*
@@ -1078,8 +1077,7 @@
* filter appropriately for the new address.
*/
sockaddr_in_init(&sin, ap, 0);
- ifreq_setaddr(SIOCADDMULTI, &ifr, sintosa(&sin));
- if ((*ifp->if_ioctl)(ifp, SIOCADDMULTI, &ifr) != 0) {
+ if (if_mcast_op(ifp, SIOCADDMULTI, sintosa(&sin)) != 0) {
LIST_REMOVE(inm, inm_list);
pool_put(&inmulti_pool, inm);
splx(s);
@@ -1107,7 +1105,6 @@
in_delmulti(struct in_multi *inm)
{
struct sockaddr_in sin;
- struct ifreq ifr;
int s = splsoftnet();
if (--inm->inm_refcount == 0) {
@@ -1126,8 +1123,7 @@
* filter.
*/
sockaddr_in_init(&sin, &inm->inm_addr, 0);
- ifreq_setaddr(SIOCDELMULTI, &ifr, sintosa(&sin));
- (*inm->inm_ifp->if_ioctl)(inm->inm_ifp, SIOCDELMULTI, &ifr);
+ if_mcast_op(inm->inm_ifp, SIOCDELMULTI, sintosa(&sin));
pool_put(&inmulti_pool, inm);
}
splx(s);
diff -r 5a87bd9464e4 -r a7fe0f6d2b45 sys/netinet/ip_carp.c
--- a/sys/netinet/ip_carp.c Wed Oct 19 01:50:27 2011 +0000
+++ b/sys/netinet/ip_carp.c Wed Oct 19 01:52:22 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ip_carp.c,v 1.45 2011/07/17 20:54:53 joerg Exp $ */
+/* $NetBSD: ip_carp.c,v 1.46 2011/10/19 01:52:22 dyoung Exp $ */
/* $OpenBSD: ip_carp.c,v 1.113 2005/11/04 08:11:54 mcbride Exp $ */
/*
@@ -30,7 +30,7 @@
#include "opt_inet.h"
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ip_carp.c,v 1.45 2011/07/17 20:54:53 joerg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_carp.c,v 1.46 2011/10/19 01:52:22 dyoung Exp $");
/*
* TODO:
@@ -2151,7 +2151,7 @@
memcpy(&mc->mc_addr, sa, sa->sa_len);
LIST_INSERT_HEAD(&sc->carp_mc_listhead, mc, mc_entries);
- error = (*ifp->if_ioctl)(ifp, SIOCADDMULTI, ifr);
+ error = if_mcast_op(ifp, SIOCADDMULTI, sa);
if (error != 0)
goto ioctl_failed;
@@ -2203,7 +2203,7 @@
return (error);
/* We no longer use this multicast address. Tell parent so. */
- error = (*ifp->if_ioctl)(ifp, SIOCDELMULTI, ifr);
+ error = if_mcast_op(ifp, SIOCDELMULTI, sa);
if (error == 0) {
/* And forget about this address. */
LIST_REMOVE(mc, mc_entries);
@@ -2222,22 +2222,12 @@
{
struct ifnet *ifp = sc->sc_carpdev; /* Parent. */
struct carp_mc_entry *mc;
- union {
- struct ifreq ifreq;
- struct {
- char ifr_name[IFNAMSIZ];
- struct sockaddr_storage ifr_ss;
- } ifreq_storage;
- } u;
- struct ifreq *ifr = &u.ifreq;
if (ifp == NULL)
return;
- memcpy(ifr->ifr_name, ifp->if_xname, IFNAMSIZ);
while ((mc = LIST_FIRST(&sc->carp_mc_listhead)) != NULL) {
- memcpy(&ifr->ifr_addr, &mc->mc_addr, mc->mc_addr.ss_len);
- (void)(*ifp->if_ioctl)(ifp, SIOCDELMULTI, ifr);
+ (void)if_mcast_op(ifp, SIOCDELMULTI, sstosa(&mc->mc_addr));
LIST_REMOVE(mc, mc_entries);
free(mc, M_DEVBUF);
}
diff -r 5a87bd9464e4 -r a7fe0f6d2b45 sys/netinet/ip_mroute.c
--- a/sys/netinet/ip_mroute.c Wed Oct 19 01:50:27 2011 +0000
+++ b/sys/netinet/ip_mroute.c Wed Oct 19 01:52:22 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ip_mroute.c,v 1.120 2011/08/31 18:31:03 plunky Exp $ */
+/* $NetBSD: ip_mroute.c,v 1.121 2011/10/19 01:52:22 dyoung Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -93,7 +93,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ip_mroute.c,v 1.120 2011/08/31 18:31:03 plunky Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_mroute.c,v 1.121 2011/10/19 01:52:22 dyoung Exp $");
#include "opt_inet.h"
#include "opt_ipsec.h"
@@ -787,7 +787,6 @@
struct vif *vifp;
struct ifaddr *ifa;
struct ifnet *ifp;
- struct ifreq ifr;
int error, s;
struct sockaddr_in sin;
@@ -867,8 +866,7 @@
/* Enable promiscuous reception of all IP multicasts. */
sockaddr_in_init(&sin, &zeroin_addr, 0);
- ifreq_setaddr(SIOCADDMULTI, &ifr, sintosa(&sin));
- error = (*ifp->if_ioctl)(ifp, SIOCADDMULTI, &ifr);
+ error = if_mcast_op(ifp, SIOCADDMULTI, sintosa(&sin));
if (error)
return (error);
}
@@ -926,7 +924,6 @@
{
struct mbuf *m, *n;
struct ifnet *ifp;
- struct ifreq ifr;
struct sockaddr_in sin;
callout_stop(&vifp->v_repq_ch);
@@ -951,9 +948,8 @@
#endif
} else {
sockaddr_in_init(&sin, &zeroin_addr, 0);
- ifreq_setaddr(SIOCDELMULTI, &ifr, sintosa(&sin));
ifp = vifp->v_ifp;
- (*ifp->if_ioctl)(ifp, SIOCDELMULTI, &ifr);
+ if_mcast_op(ifp, SIOCDELMULTI, sintosa(&sin));
}
memset((void *)vifp, 0, sizeof(*vifp));
}
diff -r 5a87bd9464e4 -r a7fe0f6d2b45 sys/netinet6/in6.c
--- a/sys/netinet6/in6.c Wed Oct 19 01:50:27 2011 +0000
+++ b/sys/netinet6/in6.c Wed Oct 19 01:52:22 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: in6.c,v 1.157 2011/02/06 19:12:55 dyoung Exp $ */
+/* $NetBSD: in6.c,v 1.158 2011/10/19 01:53:07 dyoung Exp $ */
/* $KAME: in6.c,v 1.198 2001/07/18 09:12:38 itojun Exp $ */
/*
@@ -62,7 +62,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: in6.c,v 1.157 2011/02/06 19:12:55 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in6.c,v 1.158 2011/10/19 01:53:07 dyoung Exp $");
#include "opt_inet.h"
#include "opt_pfil_hooks.h"
@@ -1753,8 +1753,8 @@
ia->ia_addr = *sin6;
- if (ifacount <= 1 &&
- (error = (*ifp->if_ioctl)(ifp, SIOCINITIFADDR, ia)) != 0) {
+ if (ifacount <= 1 &&
+ (error = if_addr_init(ifp, &ia->ia_ifa, true)) != 0) {
splx(s);
return error;
}
diff -r 5a87bd9464e4 -r a7fe0f6d2b45 sys/netinet6/ip6_mroute.c
--- a/sys/netinet6/ip6_mroute.c Wed Oct 19 01:50:27 2011 +0000
+++ b/sys/netinet6/ip6_mroute.c Wed Oct 19 01:52:22 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ip6_mroute.c,v 1.101 2011/08/31 18:31:03 plunky Exp $ */
+/* $NetBSD: ip6_mroute.c,v 1.102 2011/10/19 01:53:07 dyoung Exp $ */
/* $KAME: ip6_mroute.c,v 1.49 2001/07/25 09:21:18 jinmei Exp $ */
/*
@@ -117,7 +117,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ip6_mroute.c,v 1.101 2011/08/31 18:31:03 plunky Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip6_mroute.c,v 1.102 2011/10/19 01:53:07 dyoung Exp $");
#include "opt_inet.h"
#include "opt_mrouting.h"
@@ -512,7 +512,7 @@
mifi_t mifi;
int i;
struct ifnet *ifp;
- struct in6_ifreq ifr;
+ struct sockaddr_in6 sin6;
struct mf6c *rt;
struct rtdetq *rte;
int s;
@@ -538,10 +538,11 @@
for (mifi = 0; mifi < nummifs; mifi++) {
if (mif6table[mifi].m6_ifp &&
!(mif6table[mifi].m6_flags & MIFF_REGISTER)) {
- ifr.ifr_addr.sin6_family = AF_INET6;
- ifr.ifr_addr.sin6_addr= in6addr_any;
+ sin6.sin6_family = AF_INET6;
+ sin6.sin6_addr = in6addr_any;
ifp = mif6table[mifi].m6_ifp;
- (*ifp->if_ioctl)(ifp, SIOCDELMULTI, &ifr);
+ if_mcast_op(ifp, SIOCDELMULTI,
+ sin6tocsa(&sin6));
}
}
}
@@ -643,7 +644,7 @@
{
struct mif6 *mifp;
struct ifnet *ifp;
- struct in6_ifreq ifr;
+ struct sockaddr_in6 sin6;
int error, s;
#ifdef notyet
struct tbf *m_tbf = tbftable + mifcp->mif6c_mifi;
@@ -686,9 +687,9 @@
* Enable promiscuous reception of all IPv6 multicasts
* from the interface.
*/
- ifr.ifr_addr.sin6_family = AF_INET6;
- ifr.ifr_addr.sin6_addr = in6addr_any;
- error = (*ifp->if_ioctl)(ifp, SIOCADDMULTI, &ifr);
+ sin6.sin6_family = AF_INET6;
+ sin6.sin6_addr = in6addr_any;
+ error = if_mcast_op(ifp, SIOCADDMULTI, sin6tosa(&sin6));
splx(s);
if (error)
return error;
@@ -731,7 +732,7 @@
struct mif6 *mifp = mif6table + *mifip;
mifi_t mifi;
struct ifnet *ifp;
- struct in6_ifreq ifr;
+ struct sockaddr_in6 sin6;
int s;
if (*mifip >= nummifs)
@@ -748,9 +749,9 @@
*/
ifp = mifp->m6_ifp;
- ifr.ifr_addr.sin6_family = AF_INET6;
- ifr.ifr_addr.sin6_addr = in6addr_any;
- (*ifp->if_ioctl)(ifp, SIOCDELMULTI, &ifr);
+ sin6.sin6_family = AF_INET6;
+ sin6.sin6_addr = in6addr_any;
+ if_mcast_op(ifp, SIOCDELMULTI, sin6tosa(&sin6));
} else {
Home |
Main Index |
Thread Index |
Old Index