svn commit: r276463 - projects/ifnet/sys/netinet6
Gleb Smirnoff
glebius at FreeBSD.org
Wed Dec 31 10:01:12 UTC 2014
Author: glebius
Date: Wed Dec 31 10:01:10 2014
New Revision: 276463
URL: https://svnweb.freebsd.org/changeset/base/276463
Log:
- Mechanically convert access to different ifnet fields that moved to ifdriver
to inline functions.
- Other small changes to adopt to new ifnet world order.
Sponsored by: Netflix
Sponsored by: Nginx, Inc.
Modified:
projects/ifnet/sys/netinet6/icmp6.c
projects/ifnet/sys/netinet6/in6.c
projects/ifnet/sys/netinet6/in6_ifattach.c
projects/ifnet/sys/netinet6/nd6.c
projects/ifnet/sys/netinet6/nd6_nbr.c
projects/ifnet/sys/netinet6/nd6_rtr.c
Modified: projects/ifnet/sys/netinet6/icmp6.c
==============================================================================
--- projects/ifnet/sys/netinet6/icmp6.c Wed Dec 31 10:00:43 2014 (r276462)
+++ projects/ifnet/sys/netinet6/icmp6.c Wed Dec 31 10:01:10 2014 (r276463)
@@ -2420,11 +2420,11 @@ icmp6_redirect_input(struct mbuf *m, int
lladdrlen = ndopts.nd_opts_tgt_lladdr->nd_opt_len << 3;
}
- if (lladdr && ((ifp->if_addrlen + 2 + 7) & ~7) != lladdrlen) {
+ if (lladdr && ((if_addrlen(ifp)+ 2 + 7) & ~7) != lladdrlen) {
nd6log((LOG_INFO, "%s: lladdrlen mismatch for %s "
"(if %d, icmp6 packet %d): %s\n",
__func__, ip6_sprintf(ip6buf, &redtgt6),
- ifp->if_addrlen, lladdrlen - 2,
+ if_addrlen(ifp), lladdrlen - 2,
icmp6_redirect_diag(&src6, &reddst6, &redtgt6)));
goto bad;
}
@@ -2538,7 +2538,7 @@ icmp6_redirect_output(struct mbuf *m0, s
maxlen = min(IPV6_MMTU, maxlen);
/* just for safety */
if (maxlen < sizeof(struct ip6_hdr) + sizeof(struct icmp6_hdr) +
- ((sizeof(struct nd_opt_hdr) + ifp->if_addrlen + 7) & ~7)) {
+ ((sizeof(struct nd_opt_hdr) + if_addrlen(ifp) + 7) & ~7)) {
goto fail;
}
@@ -2617,7 +2617,7 @@ icmp6_redirect_output(struct mbuf *m0, s
if (ln == NULL)
goto nolladdropt;
- len = sizeof(*nd_opt) + ifp->if_addrlen;
+ len = sizeof(*nd_opt) + if_addrlen(ifp);
len = (len + 7) & ~7; /* round by 8 */
/* safety check */
if (len + (p - (u_char *)ip6) > maxlen)
@@ -2628,7 +2628,7 @@ icmp6_redirect_output(struct mbuf *m0, s
nd_opt->nd_opt_type = ND_OPT_TARGET_LINKADDR;
nd_opt->nd_opt_len = len >> 3;
lladdr = (char *)(nd_opt + 1);
- bcopy(&ln->ll_addr, lladdr, ifp->if_addrlen);
+ bcopy(&ln->ll_addr, lladdr, if_addrlen(ifp));
p += len;
}
}
Modified: projects/ifnet/sys/netinet6/in6.c
==============================================================================
--- projects/ifnet/sys/netinet6/in6.c Wed Dec 31 10:00:43 2014 (r276462)
+++ projects/ifnet/sys/netinet6/in6.c Wed Dec 31 10:01:10 2014 (r276463)
@@ -753,11 +753,7 @@ aifaddr_out:
}
default:
- if (ifp->if_ioctl == NULL) {
- error = EOPNOTSUPP;
- goto out;
- }
- error = (*ifp->if_ioctl)(ifp, cmd, data);
+ error = if_ioctl(ifp, cmd, data);
goto out;
}
@@ -1402,9 +1398,9 @@ in6_notify_ifa(struct ifnet *ifp, struct
IF_ADDR_RUNLOCK(ifp);
}
- if (ifacount <= 1 && ifp->if_ioctl) {
- error = (*ifp->if_ioctl)(ifp, SIOCSIFADDR, (caddr_t)ia);
- if (error)
+ if (ifacount <= 1) {
+ error = if_ioctl(ifp, SIOCSIFADDR, (caddr_t)ia);
+ if (error != 0 && error != EOPNOTSUPP)
return (error);
}
@@ -1963,7 +1959,7 @@ in6_setmaxmtu(void)
int
in6_if2idlen(struct ifnet *ifp)
{
- switch (ifp->if_type) {
+ switch (if_type(ifp)) {
case IFT_ETHER: /* RFC2464 */
#ifdef IFT_PROPVIRTUAL
case IFT_PROPVIRTUAL: /* XXX: no RFC. treat it as ether */
@@ -2007,7 +2003,7 @@ in6_if2idlen(struct ifnet *ifp)
* we always use the constant, but make an explicit notice
* indicating the "unknown" case.
*/
- printf("in6_if2idlen: unknown link type (%d)\n", ifp->if_type);
+ printf("%s: unknown link type (%d)\n", __func__, if_type(ifp));
return (64);
}
}
@@ -2167,7 +2163,7 @@ in6_lltable_lookup(struct lltable *llt,
}
lle->la_flags = flags & ~LLE_CREATE;
if ((flags & (LLE_CREATE | LLE_IFADDR)) == (LLE_CREATE | LLE_IFADDR)) {
- bcopy(IF_LLADDR(ifp), &lle->ll_addr, ifp->if_addrlen);
+ bcopy(if_lladdr(ifp), &lle->ll_addr, if_addrlen(ifp));
lle->la_flags |= (LLE_VALID | LLE_STATIC);
}
@@ -2259,10 +2255,10 @@ in6_lltable_dump(struct lltable *llt, st
sdl = &ndpc.sdl;
sdl->sdl_family = AF_LINK;
sdl->sdl_len = sizeof(*sdl);
- sdl->sdl_alen = ifp->if_addrlen;
+ sdl->sdl_alen = if_addrlen(ifp);
sdl->sdl_index = ifp->if_index;
- sdl->sdl_type = ifp->if_type;
- bcopy(&lle->ll_addr, LLADDR(sdl), ifp->if_addrlen);
+ sdl->sdl_type = if_type(ifp);
+ bcopy(&lle->ll_addr, LLADDR(sdl), if_addrlen(ifp));
ndpc.rtm.rtm_rmx.rmx_expire =
lle->la_flags & LLE_STATIC ? 0 : lle->la_expire;
ndpc.rtm.rtm_flags |= (RTF_HOST | RTF_LLDATA);
@@ -2283,11 +2279,13 @@ in6_domifattach(struct ifnet *ifp)
struct in6_ifextra *ext;
/* There are not IPv6-capable interfaces. */
- switch (ifp->if_type) {
+ switch (if_type(ifp)) {
case IFT_PFLOG:
case IFT_PFSYNC:
case IFT_USB:
return (NULL);
+ default:
+ break;
}
ext = (struct in6_ifextra *)malloc(sizeof(*ext), M_IFADDR, M_WAITOK);
bzero(ext, sizeof(*ext));
Modified: projects/ifnet/sys/netinet6/in6_ifattach.c
==============================================================================
--- projects/ifnet/sys/netinet6/in6_ifattach.c Wed Dec 31 10:00:43 2014 (r276462)
+++ projects/ifnet/sys/netinet6/in6_ifattach.c Wed Dec 31 10:01:10 2014 (r276463)
@@ -266,7 +266,7 @@ found:
addrlen = sdl->sdl_alen;
/* get EUI64 */
- switch (ifp->if_type) {
+ switch (if_type(ifp)) {
case IFT_BRIDGE:
case IFT_ETHER:
case IFT_L2VLAN:
@@ -702,7 +702,7 @@ in6_ifattach(struct ifnet *ifp, struct i
/*
* quirks based on interface type
*/
- switch (ifp->if_type) {
+ switch (if_type(ifp)) {
case IFT_STF:
/*
* 6to4 interface is a very special kind of beast.
Modified: projects/ifnet/sys/netinet6/nd6.c
==============================================================================
--- projects/ifnet/sys/netinet6/nd6.c Wed Dec 31 10:00:43 2014 (r276462)
+++ projects/ifnet/sys/netinet6/nd6.c Wed Dec 31 10:01:10 2014 (r276463)
@@ -187,7 +187,7 @@ nd6_ifattach(struct ifnet *ifp)
* default regardless of the V_ip6_auto_linklocal configuration to
* give a reasonable default behavior.
*/
- if ((V_ip6_auto_linklocal && ifp->if_type != IFT_BRIDGE) ||
+ if ((V_ip6_auto_linklocal && if_type(ifp) != IFT_BRIDGE) ||
(ifp->if_flags & IFF_LOOPBACK))
nd->flags |= ND6_IFF_AUTO_LINKLOCAL;
/*
@@ -197,9 +197,8 @@ nd6_ifattach(struct ifnet *ifp)
* prevent the interface from accepting RA messages arrived
* on one of the member interfaces with ND6_IFF_ACCEPT_RTADV.
*/
- if (V_ip6_accept_rtadv &&
- !(ifp->if_flags & IFF_LOOPBACK) &&
- (ifp->if_type != IFT_BRIDGE))
+ if (V_ip6_accept_rtadv && !(ifp->if_flags & IFF_LOOPBACK) &&
+ (if_type(ifp) != IFT_BRIDGE))
nd->flags |= ND6_IFF_ACCEPT_RTADV;
if (V_ip6_no_radr && !(ifp->if_flags & IFF_LOOPBACK))
nd->flags |= ND6_IFF_NO_RADR;
@@ -236,7 +235,7 @@ nd6_setmtu0(struct ifnet *ifp, struct nd
omaxmtu = ndi->maxmtu;
- switch (ifp->if_type) {
+ switch (if_type(ifp)) {
case IFT_ARCNET:
ndi->maxmtu = MIN(ARC_PHDS_MAXMTU, ifp->if_mtu); /* RFC2497 */
break;
@@ -1597,10 +1596,9 @@ nd6_cache_lladdr(struct ifnet *ifp, stru
return (NULL);
olladdr = (ln->la_flags & LLE_VALID) ? 1 : 0;
- if (olladdr && lladdr) {
- llchange = bcmp(lladdr, &ln->ll_addr,
- ifp->if_addrlen);
- } else
+ if (olladdr && lladdr)
+ llchange = bcmp(lladdr, &ln->ll_addr, if_addrlen(ifp));
+ else
llchange = 0;
/*
@@ -1617,9 +1615,9 @@ nd6_cache_lladdr(struct ifnet *ifp, stru
if (lladdr) { /* (3-5) and (7) */
/*
* Record source link-layer address
- * XXX is it dependent to ifp->if_type?
+ * XXX is it dependent to if_type(ifp)?
*/
- bcopy(lladdr, &ln->ll_addr, ifp->if_addrlen);
+ bcopy(lladdr, &ln->ll_addr, if_addrlen(ifp));
ln->la_flags |= LLE_VALID;
EVENTHANDLER_INVOKE(lle_event, ln, LLENTRY_RESOLVED);
}
@@ -1916,8 +1914,9 @@ sendpkt:
if ((ifp->if_flags & IFF_LOOPBACK) == 0)
origifp = ifp;
-
- error = (*ifp->if_output)(origifp, m, (struct sockaddr *)dst, NULL);
+
+ /* XXXGL */
+ error = ifp->if_ops->ifop_output(origifp, m, (struct sockaddr *)dst, NULL);
return (error);
}
@@ -2151,7 +2150,8 @@ nd6_output_lle(struct ifnet *ifp, struct
if ((ifp->if_flags & IFF_LOOPBACK) == 0)
origifp = ifp;
- error = (*ifp->if_output)(origifp, m, (struct sockaddr *)dst, NULL);
+ /* XXXGL */
+ error = ifp->if_ops->ifop_output(origifp, m, (struct sockaddr *)dst, NULL);
return (error);
}
@@ -2173,7 +2173,7 @@ nd6_output_flush(struct ifnet *ifp, stru
while (m_head) {
m = m_head;
m_head = m_head->m_nextpkt;
- error = (*ifp->if_output)(ifp, m, (struct sockaddr *)dst, NULL);
+ error = if_output(ifp, m, (struct sockaddr *)dst, NULL);
}
/*
@@ -2196,7 +2196,7 @@ nd6_need_cache(struct ifnet *ifp)
* RFC2893 says:
* - unidirectional tunnels needs no ND
*/
- switch (ifp->if_type) {
+ switch (if_type(ifp)) {
case IFT_ARCNET:
case IFT_ETHER:
case IFT_FDDI:
@@ -2290,7 +2290,7 @@ nd6_storelladdr(struct ifnet *ifp, struc
if (m != NULL && m->m_flags & M_MCAST) {
int i;
- switch (ifp->if_type) {
+ switch (if_type(ifp)) {
case IFT_ETHER:
case IFT_FDDI:
#ifdef IFT_L2VLAN
@@ -2309,7 +2309,7 @@ nd6_storelladdr(struct ifnet *ifp, struc
* netbsd can use if_broadcastaddr, but we don't do so
* to reduce # of ifdef.
*/
- for (i = 0; i < ifp->if_addrlen; i++)
+ for (i = 0; i < if_addrlen(ifp); i++)
desten[i] = ~0;
return (0);
case IFT_ARCNET:
@@ -2336,7 +2336,7 @@ nd6_storelladdr(struct ifnet *ifp, struc
return (1);
}
- bcopy(&ln->ll_addr, desten, ifp->if_addrlen);
+ bcopy(&ln->ll_addr, desten, if_addrlen(ifp));
if (pflags != NULL)
*pflags = ln->la_flags;
LLE_RUNLOCK(ln);
Modified: projects/ifnet/sys/netinet6/nd6_nbr.c
==============================================================================
--- projects/ifnet/sys/netinet6/nd6_nbr.c Wed Dec 31 10:00:43 2014 (r276462)
+++ projects/ifnet/sys/netinet6/nd6_nbr.c Wed Dec 31 10:01:10 2014 (r276463)
@@ -286,11 +286,11 @@ nd6_ns_input(struct mbuf *m, int off, in
if (((struct in6_ifaddr *)ifa)->ia6_flags & IN6_IFF_DUPLICATED)
goto freeit;
- if (lladdr && ((ifp->if_addrlen + 2 + 7) & ~7) != lladdrlen) {
+ if (lladdr && ((if_addrlen(ifp) + 2 + 7) & ~7) != lladdrlen) {
nd6log((LOG_INFO, "nd6_ns_input: lladdrlen mismatch for %s "
"(if %d, NS packet %d)\n",
ip6_sprintf(ip6bufs, &taddr6),
- ifp->if_addrlen, lladdrlen - 2));
+ if_addrlen(ifp), lladdrlen - 2));
goto bad;
}
@@ -404,7 +404,7 @@ nd6_ns_output(struct ifnet *ifp, const s
/* estimate the size of message */
maxlen = sizeof(*ip6) + sizeof(*nd_ns);
- maxlen += (sizeof(struct nd_opt_hdr) + ifp->if_addrlen + 7) & ~7;
+ maxlen += (sizeof(struct nd_opt_hdr) + if_addrlen(ifp) + 7) & ~7;
if (max_linkhdr + maxlen >= MCLBYTES) {
#ifdef DIAGNOSTIC
printf("nd6_ns_output: max_linkhdr + maxlen >= MCLBYTES "
@@ -551,7 +551,7 @@ nd6_ns_output(struct ifnet *ifp, const s
* Unicast NS SHOULD add one add the option
*/
if (!dad && (mac = nd6_ifptomac(ifp))) {
- int optlen = sizeof(struct nd_opt_hdr) + ifp->if_addrlen;
+ int optlen = sizeof(struct nd_opt_hdr) + if_addrlen(ifp);
struct nd_opt_hdr *nd_opt = (struct nd_opt_hdr *)(nd_ns + 1);
/* 8 byte alignments... */
optlen = (optlen + 7) & ~7;
@@ -562,7 +562,7 @@ nd6_ns_output(struct ifnet *ifp, const s
bzero((caddr_t)nd_opt, optlen);
nd_opt->nd_opt_type = ND_OPT_SOURCE_LINKADDR;
nd_opt->nd_opt_len = optlen >> 3;
- bcopy(mac, (caddr_t)(nd_opt + 1), ifp->if_addrlen);
+ bcopy(mac, (caddr_t)(nd_opt + 1), if_addrlen(ifp));
}
ip6->ip6_plen = htons((u_short)icmp6len);
@@ -719,10 +719,10 @@ nd6_na_input(struct mbuf *m, int off, in
goto freeit;
}
- if (lladdr && ((ifp->if_addrlen + 2 + 7) & ~7) != lladdrlen) {
+ if (lladdr && ((if_addrlen(ifp) + 2 + 7) & ~7) != lladdrlen) {
nd6log((LOG_INFO, "nd6_na_input: lladdrlen mismatch for %s "
"(if %d, NA packet %d)\n", ip6_sprintf(ip6bufs, &taddr6),
- ifp->if_addrlen, lladdrlen - 2));
+ if_addrlen(ifp), lladdrlen - 2));
goto bad;
}
@@ -742,14 +742,14 @@ nd6_na_input(struct mbuf *m, int off, in
* If the link-layer has address, and no lladdr option came,
* discard the packet.
*/
- if (ifp->if_addrlen && lladdr == NULL) {
+ if (if_addrlen(ifp) && lladdr == NULL) {
goto freeit;
}
/*
* Record link-layer address, and update the state.
*/
- bcopy(lladdr, &ln->ll_addr, ifp->if_addrlen);
+ bcopy(lladdr, &ln->ll_addr, if_addrlen(ifp));
ln->la_flags |= LLE_VALID;
EVENTHANDLER_INVOKE(lle_event, ln, LLENTRY_RESOLVED);
if (is_solicited) {
@@ -781,7 +781,7 @@ nd6_na_input(struct mbuf *m, int off, in
llchange = 0;
else {
if (ln->la_flags & LLE_VALID) {
- if (bcmp(lladdr, &ln->ll_addr, ifp->if_addrlen))
+ if (bcmp(lladdr, &ln->ll_addr, if_addrlen(ifp)))
llchange = 1;
else
llchange = 0;
@@ -825,7 +825,7 @@ nd6_na_input(struct mbuf *m, int off, in
* Update link-local address, if any.
*/
if (lladdr != NULL) {
- bcopy(lladdr, &ln->ll_addr, ifp->if_addrlen);
+ bcopy(lladdr, &ln->ll_addr, if_addrlen(ifp));
ln->la_flags |= LLE_VALID;
EVENTHANDLER_INVOKE(lle_event, ln,
LLENTRY_RESOLVED);
@@ -977,7 +977,7 @@ nd6_na_output_fib(struct ifnet *ifp, con
/* estimate the size of message */
maxlen = sizeof(*ip6) + sizeof(*nd_na);
- maxlen += (sizeof(struct nd_opt_hdr) + ifp->if_addrlen + 7) & ~7;
+ maxlen += (sizeof(struct nd_opt_hdr) + if_addrlen(ifp) + 7) & ~7;
if (max_linkhdr + maxlen >= MCLBYTES) {
#ifdef DIAGNOSTIC
printf("nd6_na_output: max_linkhdr + maxlen >= MCLBYTES "
@@ -1070,12 +1070,12 @@ nd6_na_output_fib(struct ifnet *ifp, con
} else if (sdl0->sa_family == AF_LINK) {
struct sockaddr_dl *sdl;
sdl = (struct sockaddr_dl *)sdl0;
- if (sdl->sdl_alen == ifp->if_addrlen)
+ if (sdl->sdl_alen == if_addrlen(ifp))
mac = LLADDR(sdl);
}
}
if (tlladdr && mac) {
- int optlen = sizeof(struct nd_opt_hdr) + ifp->if_addrlen;
+ int optlen = sizeof(struct nd_opt_hdr) + if_addrlen(ifp);
struct nd_opt_hdr *nd_opt = (struct nd_opt_hdr *)(nd_na + 1);
/* roundup to 8 bytes alignment! */
@@ -1087,7 +1087,7 @@ nd6_na_output_fib(struct ifnet *ifp, con
bzero((caddr_t)nd_opt, optlen);
nd_opt->nd_opt_type = ND_OPT_TARGET_LINKADDR;
nd_opt->nd_opt_len = optlen >> 3;
- bcopy(mac, (caddr_t)(nd_opt + 1), ifp->if_addrlen);
+ bcopy(mac, (caddr_t)(nd_opt + 1), if_addrlen(ifp));
} else
flags &= ~ND_NA_FLAG_OVERRIDE;
@@ -1139,7 +1139,8 @@ nd6_na_output(struct ifnet *ifp, const s
caddr_t
nd6_ifptomac(struct ifnet *ifp)
{
- switch (ifp->if_type) {
+
+ switch (if_type(ifp)) {
case IFT_ARCNET:
case IFT_ETHER:
case IFT_FDDI:
@@ -1153,7 +1154,7 @@ nd6_ifptomac(struct ifnet *ifp)
case IFT_INFINIBAND:
case IFT_BRIDGE:
case IFT_ISO88025:
- return IF_LLADDR(ifp);
+ return if_lladdr(ifp);
default:
return NULL;
}
@@ -1476,7 +1477,7 @@ nd6_dad_duplicated(struct ifaddr *ifa, s
* To avoid over-reaction, we only apply this logic when we are
* very sure that hardware addresses are supposed to be unique.
*/
- switch (ifp->if_type) {
+ switch (if_type(ifp)) {
case IFT_ETHER:
case IFT_FDDI:
case IFT_ATM:
@@ -1494,6 +1495,8 @@ nd6_dad_duplicated(struct ifaddr *ifa, s
if_name(ifp));
}
break;
+ default:
+ break;
}
}
}
Modified: projects/ifnet/sys/netinet6/nd6_rtr.c
==============================================================================
--- projects/ifnet/sys/netinet6/nd6_rtr.c Wed Dec 31 10:00:43 2014 (r276462)
+++ projects/ifnet/sys/netinet6/nd6_rtr.c Wed Dec 31 10:01:10 2014 (r276463)
@@ -179,12 +179,12 @@ nd6_rs_input(struct mbuf *m, int off, in
lladdrlen = ndopts.nd_opts_src_lladdr->nd_opt_len << 3;
}
- if (lladdr && ((ifp->if_addrlen + 2 + 7) & ~7) != lladdrlen) {
+ if (lladdr && ((if_addrlen(ifp) + 2 + 7) & ~7) != lladdrlen) {
nd6log((LOG_INFO,
"nd6_rs_input: lladdrlen mismatch for %s "
"(if %d, RS packet %d)\n",
ip6_sprintf(ip6bufs, &saddr6),
- ifp->if_addrlen, lladdrlen - 2));
+ if_addrlen(ifp), lladdrlen - 2));
goto bad;
}
@@ -409,11 +409,11 @@ nd6_ra_input(struct mbuf *m, int off, in
lladdrlen = ndopts.nd_opts_src_lladdr->nd_opt_len << 3;
}
- if (lladdr && ((ifp->if_addrlen + 2 + 7) & ~7) != lladdrlen) {
+ if (lladdr && ((if_addrlen(ifp) + 2 + 7) & ~7) != lladdrlen) {
nd6log((LOG_INFO,
"nd6_ra_input: lladdrlen mismatch for %s "
"(if %d, RA packet %d)\n", ip6_sprintf(ip6bufs, &saddr6),
- ifp->if_addrlen, lladdrlen - 2));
+ if_addrlen(ifp), lladdrlen - 2));
goto bad;
}
@@ -1553,7 +1553,7 @@ nd6_prefix_onlink_rtrequest(struct nd_pr
struct sockaddr_dl *dl;
dl = (struct sockaddr_dl *)rt->rt_gateway;
- dl->sdl_type = rt->rt_ifp->if_type;
+ dl->sdl_type = if_type(rt->rt_ifp);
dl->sdl_index = rt->rt_ifp->if_index;
}
RADIX_NODE_HEAD_UNLOCK(rnh);
More information about the svn-src-projects
mailing list