diff options
author | glebius <glebius@FreeBSD.org> | 2012-07-31 11:31:12 +0000 |
---|---|---|
committer | glebius <glebius@FreeBSD.org> | 2012-07-31 11:31:12 +0000 |
commit | 53cb168f80fa70688bd35678b681684102548ae5 (patch) | |
tree | 8f840b0a27a43be2571c75ef1584d1ac0fc66682 /sys/netinet | |
parent | 50f531dfce8d9f2f3ad7a54b8e1e293f8efe9282 (diff) | |
download | FreeBSD-src-53cb168f80fa70688bd35678b681684102548ae5.zip FreeBSD-src-53cb168f80fa70688bd35678b681684102548ae5.tar.gz |
Some style(9) and whitespace changes.
Together with: Andrey Zonov <andrey zonov.org>
Diffstat (limited to 'sys/netinet')
-rw-r--r-- | sys/netinet/if_ether.c | 49 | ||||
-rw-r--r-- | sys/netinet/in.c | 77 |
2 files changed, 59 insertions, 67 deletions
diff --git a/sys/netinet/if_ether.c b/sys/netinet/if_ether.c index d6a7fd1..8ddf317 100644 --- a/sys/netinet/if_ether.c +++ b/sys/netinet/if_ether.c @@ -87,8 +87,8 @@ static VNET_DEFINE(int, arp_maxtries) = 5; VNET_DEFINE(int, useloopback) = 1; /* use loopback interface for * local traffic */ static VNET_DEFINE(int, arp_proxyall) = 0; -static VNET_DEFINE(int, arpt_down) = 20; /* keep incomplete entries for - * 20 seconds */ +static VNET_DEFINE(int, arpt_down) = 20; /* keep incomplete entries for + * 20 seconds */ VNET_DEFINE(struct arpstat, arpstat); /* ARP statistics, see if_arp.h */ static VNET_DEFINE(int, arp_maxhold) = 1; @@ -119,7 +119,7 @@ SYSCTL_VNET_STRUCT(_net_link_ether_arp, OID_AUTO, stats, CTLFLAG_RW, &VNET_NAME(arpstat), arpstat, "ARP statistics (struct arpstat, net/if_arp.h)"); SYSCTL_VNET_INT(_net_link_ether_inet, OID_AUTO, maxhold, CTLFLAG_RW, - &VNET_NAME(arp_maxhold), 0, + &VNET_NAME(arp_maxhold), 0, "Number of packets to hold per ARP entry"); static void arp_init(void); @@ -197,7 +197,7 @@ arptimer(void *arg) } else { #ifdef DIAGNOSTIC struct sockaddr *l3addr = L3_ADDR(lle); - log(LOG_INFO, + log(LOG_INFO, "arptimer issue: %p, IPv4 address: \"%s\"\n", lle, inet_ntoa( ((const struct sockaddr_in *)l3addr)->sin_addr)); @@ -250,7 +250,7 @@ arprequest(struct ifnet *ifp, struct in_addr *sip, struct in_addr *tip, break; /* found it. */ } IF_ADDR_RUNLOCK(ifp); - if (sip == NULL) { + if (sip == NULL) { printf("%s: cannot find matching address\n", __func__); return; } @@ -339,7 +339,7 @@ retry: inet_ntoa(SIN(dst)->sin_addr)); m_freem(m); return (EINVAL); - } + } if ((la->la_flags & LLE_VALID) && ((la->la_flags & LLE_STATIC) || la->la_expire > time_uptime)) { @@ -358,8 +358,8 @@ retry: *lle = la; error = 0; goto done; - } - + } + if (la->la_flags & LLE_STATIC) { /* should not happen! */ log(LOG_DEBUG, "arpresolve: ouch, empty static llinfo for %s\n", inet_ntoa(SIN(dst)->sin_addr)); @@ -389,13 +389,13 @@ retry: la->la_numheld--; ARPSTAT_INC(dropped); } - } + } if (la->la_hold != NULL) { curr = la->la_hold; while (curr->m_nextpkt != NULL) curr = curr->m_nextpkt; curr->m_nextpkt = m; - } else + } else la->la_hold = m; la->la_numheld++; if (renew == 0 && (flags & LLE_EXCLUSIVE)) { @@ -510,11 +510,11 @@ SYSCTL_INT(_net_link_ether_inet, OID_AUTO, log_arp_wrong_iface, CTLFLAG_RW, &log_arp_wrong_iface, 0, "log arp packets arriving on the wrong interface"); SYSCTL_INT(_net_link_ether_inet, OID_AUTO, log_arp_movements, CTLFLAG_RW, - &log_arp_movements, 0, - "log arp replies from MACs different than the one in the cache"); + &log_arp_movements, 0, + "log arp replies from MACs different than the one in the cache"); SYSCTL_INT(_net_link_ether_inet, OID_AUTO, log_arp_permanent_modify, CTLFLAG_RW, - &log_arp_permanent_modify, 0, - "log arp replies from MACs different than the one in the permanent arp entry"); + &log_arp_permanent_modify, 0, + "log arp replies from MACs different than the one in the permanent arp entry"); static void @@ -550,7 +550,7 @@ in_arpinput(struct mbuf *m) } ah = mtod(m, struct arphdr *); - /* + /* * ARP is only for IPv4 so we can reject packets with * a protocol length not equal to an IPv4 address. */ @@ -686,7 +686,7 @@ match: sin.sin_addr = isaddr; flags = (itaddr.s_addr == myaddr.s_addr) ? LLE_CREATE : 0; flags |= LLE_EXCLUSIVE; - IF_AFDATA_LOCK(ifp); + IF_AFDATA_LOCK(ifp); la = lla_lookup(LLTABLE(ifp), flags, (struct sockaddr *)&sin); IF_AFDATA_UNLOCK(ifp); if (la != NULL) { @@ -716,7 +716,7 @@ match: goto reply; } if (log_arp_movements) { - log(LOG_INFO, "arp: %s moved from %*D " + log(LOG_INFO, "arp: %s moved from %*D " "to %*D on %s\n", inet_ntoa(isaddr), ifp->if_addrlen, @@ -725,7 +725,7 @@ match: ifp->if_xname); } } - + if (ifp->if_addrlen != ah->ar_hln) { LLE_WUNLOCK(la); log(LOG_WARNING, "arp from %*D: addr len: new %d, " @@ -751,7 +751,7 @@ match: } la->la_asked = 0; la->la_preempt = V_arp_maxtries; - /* + /* * The packets are all freed within the call to the output * routine. * @@ -787,7 +787,7 @@ reply: struct llentry *lle = NULL; sin.sin_addr = itaddr; - IF_AFDATA_LOCK(ifp); + IF_AFDATA_LOCK(ifp); lle = lla_lookup(LLTABLE(ifp), 0, (struct sockaddr *)&sin); IF_AFDATA_UNLOCK(ifp); @@ -846,8 +846,7 @@ reply: RTFREE_LOCKED(rt); #ifdef DEBUG_PROXY - printf("arp: proxying for %s\n", - inet_ntoa(itaddr)); + printf("arp: proxying for %s\n", inet_ntoa(itaddr)); #endif } } @@ -869,8 +868,8 @@ reply: (void)memcpy(ar_spa(ah), &itaddr, ah->ar_pln); ah->ar_op = htons(ARPOP_REPLY); ah->ar_pro = htons(ETHERTYPE_IP); /* let's be sure! */ - m->m_len = sizeof(*ah) + (2 * ah->ar_pln) + (2 * ah->ar_hln); - m->m_pkthdr.len = m->m_len; + m->m_len = sizeof(*ah) + (2 * ah->ar_pln) + (2 * ah->ar_hln); + m->m_pkthdr.len = m->m_len; m->m_pkthdr.rcvif = NULL; sa.sa_family = AF_ARP; sa.sa_len = 2; @@ -894,7 +893,7 @@ arp_ifinit(struct ifnet *ifp, struct ifaddr *ifa) if (ntohl(IA_SIN(ifa)->sin_addr.s_addr) != INADDR_ANY) { arprequest(ifp, &IA_SIN(ifa)->sin_addr, &IA_SIN(ifa)->sin_addr, IF_LLADDR(ifp)); - /* + /* * interface address is considered static entry * because the output of the arp utility shows * that L2 entry as permanent diff --git a/sys/netinet/in.c b/sys/netinet/in.c index 1beddd6..6c44a78 100644 --- a/sys/netinet/in.c +++ b/sys/netinet/in.c @@ -489,20 +489,20 @@ in_control(struct socket *so, u_long cmd, caddr_t data, struct ifnet *ifp, ia->ia_addr.sin_addr.s_addr) hostIsNew = 0; if (ifra->ifra_mask.sin_len) { - /* + /* * QL: XXX * Need to scrub the prefix here in case * the issued command is SIOCAIFADDR with * the same address, but with a different * prefix length. And if the prefix length - * is the same as before, then the call is + * is the same as before, then the call is * un-necessarily executed here. */ in_ifscrub(ifp, ia, LLE_STATIC); ia->ia_sockmask = ifra->ifra_mask; ia->ia_sockmask.sin_family = AF_INET; ia->ia_subnetmask = - ntohl(ia->ia_sockmask.sin_addr.s_addr); + ntohl(ia->ia_sockmask.sin_addr.s_addr); maskIsNew = 1; } if ((ifp->if_flags & IFF_POINTOPOINT) && @@ -886,8 +886,8 @@ in_ifinit(struct ifnet *ifp, struct in_ifaddr *ia, struct sockaddr_in *sin, RT_ADDREF(ia_ro.ro_rt); RTFREE_LOCKED(ia_ro.ro_rt); } else - error = ifa_add_loopback_route((struct ifaddr *)ia, - (struct sockaddr *)&ia->ia_addr); + error = ifa_add_loopback_route((struct ifaddr *)ia, + (struct sockaddr *)&ia->ia_addr); if (error == 0) ia->ia_flags |= IFA_RTSELF; if (ia_ro.ro_rt != NULL) @@ -902,10 +902,10 @@ in_ifinit(struct ifnet *ifp, struct in_ifaddr *ia, struct sockaddr_in *sin, ? RTF_HOST : 0) /* - * Generate a routing message when inserting or deleting + * Generate a routing message when inserting or deleting * an interface address alias. */ -static void in_addralias_rtmsg(int cmd, struct in_addr *prefix, +static void in_addralias_rtmsg(int cmd, struct in_addr *prefix, struct in_ifaddr *target) { struct route pfx_ro; @@ -928,16 +928,13 @@ static void in_addralias_rtmsg(int cmd, struct in_addr *prefix, /* QL: XXX * Point the gateway to the new interface - * address as if a new prefix route entry has - * been added through the new address alias. - * All other parts of the rtentry is accurate, + * address as if a new prefix route entry has + * been added through the new address alias. + * All other parts of the rtentry is accurate, * e.g., rt_key, rt_mask, rt_ifp etc. */ - msg_rt.rt_gateway = - (struct sockaddr *)&target->ia_addr; - rt_newaddrmsg(cmd, - (struct ifaddr *)target, - 0, &msg_rt); + msg_rt.rt_gateway = (struct sockaddr *)&target->ia_addr; + rt_newaddrmsg(cmd, (struct ifaddr *)target, 0, &msg_rt); RTFREE(pfx_ro.ro_rt); } return; @@ -985,7 +982,7 @@ in_addprefix(struct in_ifaddr *target, int flags) */ if (ia->ia_flags & IFA_ROUTE) { #ifdef RADIX_MPATH - if (ia->ia_addr.sin_addr.s_addr == + if (ia->ia_addr.sin_addr.s_addr == target->ia_addr.sin_addr.s_addr) { IN_IFADDR_RUNLOCK(); return (EEXIST); @@ -1058,7 +1055,7 @@ in_scrubprefix(struct in_ifaddr *target, u_int flags) } if (freeit && (flags & LLE_STATIC)) { error = ifa_del_loopback_route((struct ifaddr *)target, - (struct sockaddr *)&target->ia_addr); + (struct sockaddr *)&target->ia_addr); if (error == 0) target->ia_flags &= ~IFA_RTSELF; } @@ -1141,8 +1138,8 @@ in_scrubprefix(struct in_ifaddr *target, u_int flags) mask0.sin_len = sizeof(mask0); mask0.sin_family = AF_INET; mask0.sin_addr.s_addr = target->ia_subnetmask; - lltable_prefix_free(AF_INET, (struct sockaddr *)&prefix0, - (struct sockaddr *)&mask0, flags); + lltable_prefix_free(AF_INET, (struct sockaddr *)&prefix0, + (struct sockaddr *)&mask0, flags); /* * As no-one seem to have this prefix, we can remove the route. @@ -1184,14 +1181,14 @@ in_broadcast(struct in_addr in, struct ifnet *ifp) * Check for old-style (host 0) broadcast, but * taking into account that RFC 3021 obsoletes it. */ - (ia->ia_subnetmask != IN_RFC3021_MASK && - t == ia->ia_subnet)) && + (ia->ia_subnetmask != IN_RFC3021_MASK && + t == ia->ia_subnet)) && /* * Check for an all one subnetmask. These * only exist when an interface gets a secondary * address. */ - ia->ia_subnetmask != (u_long)0xffffffff) + ia->ia_subnetmask != (u_long)0xffffffff) return (1); return (0); #undef ia @@ -1300,27 +1297,24 @@ in_lltable_new(const struct sockaddr *l3addr, u_int flags) (((ntohl((d)->sin_addr.s_addr) ^ (a)->sin_addr.s_addr) & (m)->sin_addr.s_addr)) == 0 ) static void -in_lltable_prefix_free(struct lltable *llt, - const struct sockaddr *prefix, - const struct sockaddr *mask, - u_int flags) +in_lltable_prefix_free(struct lltable *llt, const struct sockaddr *prefix, + const struct sockaddr *mask, u_int flags) { const struct sockaddr_in *pfx = (const struct sockaddr_in *)prefix; const struct sockaddr_in *msk = (const struct sockaddr_in *)mask; struct llentry *lle, *next; - register int i; + int i; size_t pkts_dropped; - for (i=0; i < LLTBL_HASHTBL_SIZE; i++) { + for (i = 0; i < LLTBL_HASHTBL_SIZE; i++) { LIST_FOREACH_SAFE(lle, &llt->lle_head[i], lle_next, next) { - - /* + /* * (flags & LLE_STATIC) means deleting all entries - * including static ARP entries + * including static ARP entries. */ - if (IN_ARE_MASKED_ADDR_EQUAL((struct sockaddr_in *)L3_ADDR(lle), - pfx, msk) && - ((flags & LLE_STATIC) || !(lle->la_flags & LLE_STATIC))) { + if (IN_ARE_MASKED_ADDR_EQUAL(satosin(L3_ADDR(lle)), + pfx, msk) && ((flags & LLE_STATIC) || + !(lle->la_flags & LLE_STATIC))) { int canceled; canceled = callout_drain(&lle->la_timer); @@ -1357,19 +1351,18 @@ in_lltable_rtcheck(struct ifnet *ifp, u_int flags, const struct sockaddr *l3addr */ if (rt->rt_flags & RTF_GATEWAY) { if (!(rt->rt_flags & RTF_HOST) || !rt->rt_ifp || - rt->rt_ifp->if_type != IFT_ETHER || - (rt->rt_ifp->if_flags & - (IFF_NOARP | IFF_STATICARP)) != 0 || - memcmp(rt->rt_gateway->sa_data, l3addr->sa_data, - sizeof(in_addr_t)) != 0) { + rt->rt_ifp->if_type != IFT_ETHER || + (rt->rt_ifp->if_flags & (IFF_NOARP | IFF_STATICARP)) != 0 || + memcmp(rt->rt_gateway->sa_data, l3addr->sa_data, + sizeof(in_addr_t)) != 0) { RTFREE_LOCKED(rt); return (EINVAL); } } /* - * Make sure that at least the destination address is covered - * by the route. This is for handling the case where 2 or more + * Make sure that at least the destination address is covered + * by the route. This is for handling the case where 2 or more * interfaces have the same prefix. An incoming packet arrives * on one interface and the corresponding outgoing packet leaves * another interface. @@ -1429,7 +1422,7 @@ in_lltable_lookup(struct lltable *llt, u_int flags, const struct sockaddr *l3add hashkey = sin->sin_addr.s_addr; lleh = &llt->lle_head[LLATBL_HASH(hashkey, LLTBL_HASHMASK)]; LIST_FOREACH(lle, lleh, lle_next) { - struct sockaddr_in *sa2 = (struct sockaddr_in *)L3_ADDR(lle); + struct sockaddr_in *sa2 = satosin(L3_ADDR(lle)); if (lle->la_flags & LLE_DELETED) continue; if (sa2->sin_addr.s_addr == sin->sin_addr.s_addr) |