From 032dcc7680b14f7ce99a135b0df2c4bb48bfe458 Mon Sep 17 00:00:00 2001 From: Luigi Rizzo Date: Wed, 20 Nov 2002 19:00:54 +0000 Subject: [PATCH] Back out some style changes. They are not urgent, I will put them back in after 5.0 is out. Requested by: sam Approved by: re --- sys/net/raw_cb.c | 16 ++++++---- sys/net/raw_usrreq.c | 40 +++++++++++++++---------- sys/netinet/igmp.c | 52 ++++++++++++++++++--------------- sys/netinet/raw_ip.c | 56 ++++++++++++++++++----------------- sys/netinet/udp_usrreq.c | 63 +++++++++++++++++++++++----------------- 5 files changed, 130 insertions(+), 97 deletions(-) diff --git a/sys/net/raw_cb.c b/sys/net/raw_cb.c index 179a08fee8ac..7e45500fa694 100644 --- a/sys/net/raw_cb.c +++ b/sys/net/raw_cb.c @@ -63,9 +63,11 @@ static u_long raw_recvspace = RAWRCVQ; * of buffer space for the socket. */ int -raw_attach(struct socket *so, int proto) +raw_attach(so, proto) + register struct socket *so; + int proto; { - struct rawcb *rp = sotorawcb(so); + register struct rawcb *rp = sotorawcb(so); int error; /* @@ -90,7 +92,8 @@ raw_attach(struct socket *so, int proto) * socket resources. */ void -raw_detach(struct rawcb *rp) +raw_detach(rp) + register struct rawcb *rp; { struct socket *so = rp->rcb_socket; @@ -109,7 +112,8 @@ raw_detach(struct rawcb *rp) * Disconnect and possibly release resources. */ void -raw_disconnect(struct rawcb *rp) +raw_disconnect(rp) + struct rawcb *rp; { #ifdef notdef @@ -125,7 +129,9 @@ raw_disconnect(struct rawcb *rp) #include int -raw_bind(struct socket *so, struct mbuf *nam) +raw_bind(so, nam) + register struct socket *so; + struct mbuf *nam; { struct sockaddr *addr = mtod(nam, struct sockaddr *); register struct rawcb *rp; diff --git a/sys/net/raw_usrreq.c b/sys/net/raw_usrreq.c index 39a8819d48f5..7afab7071d6a 100644 --- a/sys/net/raw_usrreq.c +++ b/sys/net/raw_usrreq.c @@ -50,7 +50,7 @@ * Initialize raw connection block q. */ void -raw_init(void) +raw_init() { LIST_INIT(&rawcb_list); } @@ -65,15 +65,17 @@ raw_init(void) * Raw protocol interface. */ void -raw_input(struct mbuf *m0, struct sockproto *proto, - struct sockaddr *src, struct sockaddr *dst) +raw_input(m0, proto, src, dst) + struct mbuf *m0; + register struct sockproto *proto; + struct sockaddr *src, *dst; { - struct rawcb *rp; - struct mbuf *m = m0; - int sockets = 0; + register struct rawcb *rp; + register struct mbuf *m = m0; + register int sockets = 0; struct socket *last; - last = NULL; + last = 0; LIST_FOREACH(rp, &rawcb_list, list) { if (rp->rcb_proto.sp_family != proto->sp_family) continue; @@ -88,18 +90,18 @@ raw_input(struct mbuf *m0, struct sockproto *proto, * Note that if the lengths are not the same * the comparison will fail at the first byte. */ -#define equal(a1, a2) (bcmp((caddr_t)(a1), (caddr_t)(a2), a1->sa_len) == 0) - +#define equal(a1, a2) \ + (bcmp((caddr_t)(a1), (caddr_t)(a2), a1->sa_len) == 0) if (rp->rcb_laddr && !equal(rp->rcb_laddr, dst)) continue; if (rp->rcb_faddr && !equal(rp->rcb_faddr, src)) continue; if (last) { - struct mbuf *n = m_copypacket(m, M_DONTWAIT); - + struct mbuf *n; + n = m_copy(m, 0, (int)M_COPYALL); if (n) { if (sbappendaddr(&last->so_rcv, src, - n, NULL) == 0) + n, (struct mbuf *)0) == 0) /* should notify about lost packet */ m_freem(n); else { @@ -111,7 +113,8 @@ raw_input(struct mbuf *m0, struct sockproto *proto, last = rp->rcb_socket; } if (last) { - if (sbappendaddr(&last->so_rcv, src, m, NULL) == 0) + if (sbappendaddr(&last->so_rcv, src, + m, (struct mbuf *)0) == 0) m_freem(m); else { sorwakeup(last); @@ -123,7 +126,10 @@ raw_input(struct mbuf *m0, struct sockproto *proto, /*ARGSUSED*/ void -raw_ctlinput(int cmd, struct sockaddr *arg, void *dummy) +raw_ctlinput(cmd, arg, dummy) + int cmd; + struct sockaddr *arg; + void *dummy; { if (cmd < 0 || cmd > PRC_NCMDS) @@ -193,8 +199,9 @@ raw_udisconnect(struct socket *so) if (rp == 0) return EINVAL; - if (rp->rcb_faddr == 0) + if (rp->rcb_faddr == 0) { return ENOTCONN; + } raw_disconnect(rp); soisdisconnected(so); return 0; @@ -209,8 +216,9 @@ raw_upeeraddr(struct socket *so, struct sockaddr **nam) if (rp == 0) return EINVAL; - if (rp->rcb_faddr == 0) + if (rp->rcb_faddr == 0) { return ENOTCONN; + } *nam = dup_sockaddr(rp->rcb_faddr, 1); return 0; } diff --git a/sys/netinet/igmp.c b/sys/netinet/igmp.c index a109d4e7f924..929d456ec66c 100644 --- a/sys/netinet/igmp.c +++ b/sys/netinet/igmp.c @@ -76,7 +76,8 @@ static MALLOC_DEFINE(M_IGMP, "igmp", "igmp state"); -static struct router_info *find_rti(struct ifnet *ifp); +static struct router_info * + find_rti(struct ifnet *ifp); static struct igmpstat igmpstat; @@ -92,7 +93,7 @@ static struct router_info *Head; static void igmp_sendpkt(struct in_multi *, int, unsigned long); void -igmp_init(void) +igmp_init() { struct ipoption *ra; @@ -120,9 +121,10 @@ igmp_init(void) } static struct router_info * -find_rti(struct ifnet *ifp) +find_rti(ifp) + struct ifnet *ifp; { - struct router_info *rti = Head; + register struct router_info *rti = Head; #ifdef IGMP_DEBUG printf("[igmp.c, _find_rti] --> entering \n"); @@ -149,16 +151,18 @@ find_rti(struct ifnet *ifp) } void -igmp_input(struct mbuf *m, int off) +igmp_input(m, off) + register struct mbuf *m; + int off; { - int iphlen = off; - struct igmp *igmp; - struct ip *ip; - int igmplen; - struct ifnet *ifp = m->m_pkthdr.rcvif; - int minlen; - struct in_multi *inm; - struct in_ifaddr *ia; + register int iphlen = off; + register struct igmp *igmp; + register struct ip *ip; + register int igmplen; + register struct ifnet *ifp = m->m_pkthdr.rcvif; + register int minlen; + register struct in_multi *inm; + register struct in_ifaddr *ia; struct in_multistep step; struct router_info *rti; @@ -341,7 +345,8 @@ igmp_input(struct mbuf *m, int off) } void -igmp_joingroup(struct in_multi *inm) +igmp_joingroup(inm) + struct in_multi *inm; { int s = splnet(); @@ -361,7 +366,8 @@ igmp_joingroup(struct in_multi *inm) } void -igmp_leavegroup(struct in_multi *inm) +igmp_leavegroup(inm) + struct in_multi *inm; { if (inm->inm_state == IGMP_IREPORTEDLAST && inm->inm_addr.s_addr != igmp_all_hosts_group && @@ -371,9 +377,9 @@ igmp_leavegroup(struct in_multi *inm) } void -igmp_fasttimo(void) +igmp_fasttimo() { - struct in_multi *inm; + register struct in_multi *inm; struct in_multistep step; int s; @@ -403,10 +409,10 @@ igmp_fasttimo(void) } void -igmp_slowtimo(void) +igmp_slowtimo() { int s = splnet(); - struct router_info *rti = Head; + register struct router_info *rti = Head; #ifdef IGMP_DEBUG printf("[igmp.c,_slowtimo] -- > entering \n"); @@ -426,13 +432,13 @@ igmp_slowtimo(void) splx(s); } -/* - * XXX fix this static var when we remove the network code from Giant. - */ static struct route igmprt; static void -igmp_sendpkt(struct in_multi *inm, int type, unsigned long addr) +igmp_sendpkt(inm, type, addr) + struct in_multi *inm; + int type; + unsigned long addr; { struct mbuf *m; struct igmp *igmp; diff --git a/sys/netinet/raw_ip.c b/sys/netinet/raw_ip.c index 9bae95f6e4f4..8599a1baefe0 100644 --- a/sys/netinet/raw_ip.c +++ b/sys/netinet/raw_ip.c @@ -118,10 +118,10 @@ void (*ip_rsvp_force_done)(struct socket *); */ /* - * Initialize raw connection block queue. + * Initialize raw connection block q. */ void -rip_init(void) +rip_init() { INP_INFO_LOCK_INIT(&ripcbinfo, "rip"); LIST_INIT(&ripcb); @@ -138,22 +138,19 @@ rip_init(void) uma_zone_set_max(ripcbinfo.ipi_zone, maxsockets); } -/* - * XXX ripsrc is modified in rip_input, so we must be fix this - * when we want to make this code smp-friendly. - */ static struct sockaddr_in ripsrc = { sizeof(ripsrc), AF_INET }; - /* * Setup generic address and protocol structures * for raw_input routine, then pass them along with * mbuf chain. */ void -rip_input(struct mbuf *m, int off) +rip_input(m, off) + struct mbuf *m; + int off; { - struct ip *ip = mtod(m, struct ip *); - struct inpcb *inp; + register struct ip *ip = mtod(m, struct ip *); + register struct inpcb *inp; struct inpcb *last = 0; struct mbuf *opts = 0; int proto = ip->ip_p; @@ -166,14 +163,14 @@ rip_input(struct mbuf *m, int off) #endif if (inp->inp_ip_p && inp->inp_ip_p != proto) continue; - if (inp->inp_laddr.s_addr != INADDR_ANY && - inp->inp_laddr.s_addr != ip->ip_dst.s_addr) + if (inp->inp_laddr.s_addr && + inp->inp_laddr.s_addr != ip->ip_dst.s_addr) continue; - if (inp->inp_faddr.s_addr != INADDR_ANY && - inp->inp_faddr.s_addr != ip->ip_src.s_addr) + if (inp->inp_faddr.s_addr && + inp->inp_faddr.s_addr != ip->ip_src.s_addr) continue; if (last) { - struct mbuf *n = m_copypacket(m, M_DONTWAIT); + struct mbuf *n = m_copy(m, 0, (int)M_COPYALL); int policyfail = 0; if (n != NULL) { @@ -268,10 +265,13 @@ rip_input(struct mbuf *m, int off) * Tack on options user may have setup with control call. */ int -rip_output(struct mbuf *m, struct socket *so, u_long dst) +rip_output(m, so, dst) + struct mbuf *m; + struct socket *so; + u_long dst; { - struct ip *ip; - struct inpcb *inp = sotoinpcb(so); + register struct ip *ip; + register struct inpcb *inp = sotoinpcb(so); int flags = (so->so_options & SO_DONTROUTE) | IP_ALLOWBROADCAST; #ifdef MAC @@ -330,7 +330,9 @@ rip_output(struct mbuf *m, struct socket *so, u_long dst) * Raw IP socket option processing. */ int -rip_ctloutput(struct socket *so, struct sockopt *sopt) +rip_ctloutput(so, sopt) + struct socket *so; + struct sockopt *sopt; { struct inpcb *inp = sotoinpcb(so); int error, optval; @@ -458,7 +460,10 @@ rip_ctloutput(struct socket *so, struct sockopt *sopt) * interface routes. */ void -rip_ctlinput(int cmd, struct sockaddr *sa, void *vip) +rip_ctlinput(cmd, sa, vip) + int cmd; + struct sockaddr *sa; + void *vip; { struct in_ifaddr *ia; struct ifnet *ifp; @@ -516,8 +521,7 @@ SYSCTL_INT(_net_inet_raw, OID_AUTO, maxdgram, CTLFLAG_RW, SYSCTL_INT(_net_inet_raw, OID_AUTO, recvspace, CTLFLAG_RW, &rip_recvspace, 0, "Maximum incoming raw IP datagram size"); SYSCTL_INT(_net_inet_raw, OID_AUTO, olddiverterror, CTLFLAG_RW, - &rip_olddiverterror, 0, - "Return an error when creating an 'old' DIVERT socket"); + &rip_olddiverterror, 0, "Return an error when creating an 'old' DIVERT socket"); static int rip_attach(struct socket *so, int proto, struct thread *td) @@ -536,9 +540,7 @@ rip_attach(struct socket *so, int proto, struct thread *td) /* To be removed before 5.2 */ if (rip_olddiverterror && proto == IPPROTO_OLD_DIVERT) { - printf("Old IPDIVERT program needs to be recompiled, " - "or new IP proto 254 user needs " - "sysctl net.inet.raw.olddiverterror=0\n"); + printf("Old IPDIVERT program needs to be recompiled, or new IP proto 254 user needs sysctl net.inet.raw.olddiverterror=0\n"); return EPROTONOSUPPORT; } @@ -601,7 +603,7 @@ rip_bind(struct socket *so, struct sockaddr *nam, struct thread *td) if (TAILQ_EMPTY(&ifnet) || ((addr->sin_family != AF_INET) && (addr->sin_family != AF_IMPLINK)) || - (addr->sin_addr.s_addr != INADDR_ANY && + (addr->sin_addr.s_addr && ifa_ifwithaddr((struct sockaddr *)addr) == 0)) return EADDRNOTAVAIL; inp->inp_laddr = addr->sin_addr; @@ -638,7 +640,7 @@ rip_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *nam, struct mbuf *control, struct thread *td) { struct inpcb *inp = sotoinpcb(so); - u_long dst; + register u_long dst; if (so->so_state & SS_ISCONNECTED) { if (nam) { diff --git a/sys/netinet/udp_usrreq.c b/sys/netinet/udp_usrreq.c index 65455350986b..437ee4e9012c 100644 --- a/sys/netinet/udp_usrreq.c +++ b/sys/netinet/udp_usrreq.c @@ -98,15 +98,15 @@ static int udpcksum = 1; static int udpcksum = 0; /* XXX */ #endif SYSCTL_INT(_net_inet_udp, UDPCTL_CHECKSUM, checksum, CTLFLAG_RW, - &udpcksum, 0, ""); + &udpcksum, 0, ""); -int log_in_vain; /* defaults to 0 */ +int log_in_vain = 0; SYSCTL_INT(_net_inet_udp, OID_AUTO, log_in_vain, CTLFLAG_RW, &log_in_vain, 0, "Log all incoming UDP packets"); -static int blackhole; /* defaults to 0 */ +static int blackhole = 0; SYSCTL_INT(_net_inet_udp, OID_AUTO, blackhole, CTLFLAG_RW, - &blackhole, 0, "Do not send port unreachables for refused connects"); + &blackhole, 0, "Do not send port unreachables for refused connects"); struct inpcbhead udb; /* from udp_var.h */ #define udb6 udb /* for KAME src sync over BSD*'s */ @@ -120,12 +120,7 @@ struct udpstat udpstat; /* from udp_var.h */ SYSCTL_STRUCT(_net_inet_udp, UDPCTL_STATS, stats, CTLFLAG_RW, &udpstat, udpstat, "UDP statistics (struct udpstat, netinet/udp_var.h)"); -/* - * XXX warning, udp_in is not constant, so we need to fix this when - * we want to remove this code from under Giant - */ static struct sockaddr_in udp_in = { sizeof(udp_in), AF_INET }; - #ifdef INET6 struct udp_in6 { struct sockaddr_in6 uin6_sin; @@ -151,7 +146,7 @@ static int udp_output(struct inpcb *, struct mbuf *, struct sockaddr *, struct mbuf *, struct thread *); void -udp_init(void) +udp_init() { INP_INFO_LOCK_INIT(&udbinfo, "udp"); LIST_INIT(&udb); @@ -165,12 +160,14 @@ udp_init(void) } void -udp_input(struct mbuf *m, int off) +udp_input(m, off) + register struct mbuf *m; + int off; { int iphlen = off; - struct ip *ip; - struct udphdr *uh; - struct inpcb *inp; + register struct ip *ip; + register struct udphdr *uh; + register struct inpcb *inp; struct mbuf *opts = 0; int len; struct ip save_ip; @@ -314,7 +311,7 @@ udp_input(struct mbuf *m, int off) if (last != NULL) { struct mbuf *n; - n = m_copypacket(m, M_DONTWAIT); + n = m_copy(m, 0, M_COPYALL); if (n != NULL) udp_append(last, ip, n, iphlen + @@ -397,7 +394,9 @@ badunlocked: #ifdef INET6 static void -ip_2_ip6_hdr(struct ip6_hdr *ip6, struct ip *ip) +ip_2_ip6_hdr(ip6, ip) + struct ip6_hdr *ip6; + struct ip *ip; { bzero(ip6, sizeof(*ip6)); @@ -417,7 +416,11 @@ ip_2_ip6_hdr(struct ip6_hdr *ip6, struct ip *ip) * caller must properly init udp_ip6 and udp_in6 beforehand. */ static void -udp_append(struct inpcb *last, struct ip *ip, struct mbuf *n, int off) +udp_append(last, ip, n, off) + struct inpcb *last; + struct ip *ip; + struct mbuf *n; + int off; { struct sockaddr *append_sa; struct mbuf *opts = 0; @@ -486,7 +489,9 @@ udp_append(struct inpcb *last, struct ip *ip, struct mbuf *n, int off) * just wake up so that he can collect error status. */ struct inpcb * -udp_notify(struct inpcb *inp, int errno) +udp_notify(inp, errno) + register struct inpcb *inp; + int errno; { inp->inp_socket->so_error = errno; sorwakeup(inp->inp_socket); @@ -495,7 +500,10 @@ udp_notify(struct inpcb *inp, int errno) } void -udp_ctlinput(int cmd, struct sockaddr *sa, void *vip) +udp_ctlinput(cmd, sa, vip) + int cmd; + struct sockaddr *sa; + void *vip; { struct ip *ip = vip; struct udphdr *uh; @@ -630,7 +638,7 @@ udp_pcblist(SYSCTL_HANDLER_ARGS) } SYSCTL_PROC(_net_inet_udp, UDPCTL_PCBLIST, pcblist, CTLFLAG_RD, 0, 0, - udp_pcblist, "S,xinpcb", "List of active UDP sockets"); + udp_pcblist, "S,xinpcb", "List of active UDP sockets"); static int udp_getcred(SYSCTL_HANDLER_ARGS) @@ -671,11 +679,15 @@ SYSCTL_PROC(_net_inet_udp, OID_AUTO, getcred, udp_getcred, "S,xucred", "Get the xucred of a UDP connection"); static int -udp_output(struct inpcb *inp, struct mbuf *m, struct sockaddr *addr, - struct mbuf *control, struct thread *td) +udp_output(inp, m, addr, control, td) + register struct inpcb *inp; + struct mbuf *m; + struct sockaddr *addr; + struct mbuf *control; + struct thread *td; { - struct udpiphdr *ui; - int len = m->m_pkthdr.len; + register struct udpiphdr *ui; + register int len = m->m_pkthdr.len; struct in_addr faddr, laddr; struct cmsghdr *cm; struct sockaddr_in *sin, src; @@ -835,11 +847,10 @@ release: } u_long udp_sendspace = 9216; /* really max datagram size */ - + /* 40 1K datagrams */ SYSCTL_INT(_net_inet_udp, UDPCTL_MAXDGRAM, maxdgram, CTLFLAG_RW, &udp_sendspace, 0, "Maximum outgoing UDP datagram size"); -/* XXX having this conditional is just silly! */ u_long udp_recvspace = 40 * (1024 + #ifdef INET6 sizeof(struct sockaddr_in6)