On 08/04/13(Mon) 18:38, Philip Guenther wrote:
> On Mon, Apr 8, 2013 at 6:30 AM, Martin Pieuchot <[email protected]>
> wrote:
> > Diff below remove various external variable declaration from sources
> > files and move them to the corresponding header with an appropriate
> > comment if necessary.
> >
> > ok?
>
> I like the idea. I agree with Alexey about copying forward the #ifdefs.
Sure, updated diff below also with some more declarations I missed in my
previous email.
> > --- netinet/ip_icmp.c 18 Sep 2012 12:35:51 -0000 1.96
> > +++ netinet/ip_icmp.c 8 Apr 2013 13:23:23 -0000
> > @@ -125,6 +125,9 @@ void icmp_mtudisc_timeout(struct rtentry
> > int icmp_ratelimit(const struct in_addr *, const int, const int);
> > void icmp_redirect_timeout(struct rtentry *, struct rttimer *);
> >
> > +/* from ip_input.c */
> > +extern u_char ip_protox[];
> > +
> > extern struct protosw inetsw[];
>
> No header file love for ip_protox and inetsw?
Not for the moment, I didn't want to send a (too) big diff but I'll
continue cleaning the various extern declarations in our network stack.
> (Ideally, IMO, the end result would only have 'extern' in top-level
> declarations in .h files)
That's what I think too.
ok?
Index: net/if_pflow.c
===================================================================
RCS file: /home/ncvs/src/sys/net/if_pflow.c,v
retrieving revision 1.27
diff -u -p -r1.27 if_pflow.c
--- net/if_pflow.c 28 Mar 2013 23:10:05 -0000 1.27
+++ net/if_pflow.c 9 Apr 2013 09:46:17 -0000
@@ -106,10 +106,6 @@ struct if_clone pflow_cloner =
IF_CLONE_INITIALIZER("pflow", pflow_clone_create,
pflow_clone_destroy);
-/* from in_pcb.c */
-extern int ipport_hifirstauto;
-extern int ipport_hilastauto;
-
/* from udp_usrreq.c */
extern int udpcksum;
Index: net/if_pppoe.c
===================================================================
RCS file: /home/ncvs/src/sys/net/if_pppoe.c,v
retrieving revision 1.36
diff -u -p -r1.36 if_pppoe.c
--- net/if_pppoe.c 28 Mar 2013 16:45:16 -0000 1.36
+++ net/if_pppoe.c 9 Apr 2013 09:46:17 -0000
@@ -152,8 +152,6 @@ struct pppoe_softc {
struct ifqueue pppoediscinq;
struct ifqueue pppoeinq;
-extern int sppp_ioctl(struct ifnet *, unsigned long, void *);
-
/* input routines */
static void pppoe_disc_input(struct mbuf *);
static void pppoe_dispatch_disc_pkt(struct mbuf *, int);
Index: net/pf.c
===================================================================
RCS file: /home/ncvs/src/sys/net/pf.c,v
retrieving revision 1.821
diff -u -p -r1.821 pf.c
--- net/pf.c 29 Mar 2013 13:16:14 -0000 1.821
+++ net/pf.c 9 Apr 2013 09:46:17 -0000
@@ -89,7 +89,7 @@
#ifdef INET6
#include <netinet/ip6.h>
-#include <netinet/in_pcb.h>
+#include <netinet6/ip6_var.h>
#include <netinet/icmp6.h>
#include <netinet6/nd6.h>
#include <netinet6/ip6_divert.h>
@@ -5712,9 +5712,7 @@ pf_routable(struct pf_addr *addr, sa_fam
struct sockaddr_in *dst;
int ret = 1;
int check_mpath;
- extern int ipmultipath;
#ifdef INET6
- extern int ip6_multipath;
struct sockaddr_in6 *dst6;
struct route_in6 ro;
#else
Index: net/pfkeyv2_parsemessage.c
===================================================================
RCS file: /home/ncvs/src/sys/net/pfkeyv2_parsemessage.c,v
retrieving revision 1.46
diff -u -p -r1.46 pfkeyv2_parsemessage.c
--- net/pfkeyv2_parsemessage.c 29 Jun 2012 14:48:04 -0000 1.46
+++ net/pfkeyv2_parsemessage.c 9 Apr 2013 09:46:17 -0000
@@ -76,14 +76,13 @@
#include <sys/mbuf.h>
#include <sys/proc.h>
#include <netinet/ip_ipsp.h>
+#include <netinet/ip_var.h>
#include <net/pfkeyv2.h>
#if NPF > 0
#include <net/if.h>
#include <net/pfvar.h>
#endif
-
-extern int encdebug;
#ifdef ENCDEBUG
#define DPRINTF(x) if (encdebug) printf x
Index: net/radix_mpath.c
===================================================================
RCS file: /home/ncvs/src/sys/net/radix_mpath.c,v
retrieving revision 1.18
diff -u -p -r1.18 radix_mpath.c
--- net/radix_mpath.c 7 May 2010 13:33:16 -0000 1.18
+++ net/radix_mpath.c 9 Apr 2013 09:46:17 -0000
@@ -47,9 +47,12 @@
#include <dev/rndvar.h>
#include <netinet/in.h>
+#include <netinet/ip_var.h>
-extern int ipmultipath;
-extern int ip6_multipath;
+#ifdef INET6
+#include <netinet/ip6.h>
+#include <netinet6/ip6_var.h>
+#endif
u_int32_t rn_mpath_hash(struct route *, u_int32_t *);
Index: netinet/igmp.c
===================================================================
RCS file: /home/ncvs/src/sys/netinet/igmp.c,v
retrieving revision 1.31
diff -u -p -r1.31 igmp.c
--- netinet/igmp.c 20 Apr 2010 22:05:43 -0000 1.31
+++ netinet/igmp.c 9 Apr 2013 09:46:17 -0000
@@ -563,9 +563,6 @@ igmp_sendpkt(struct in_multi *inm, int t
struct igmp *igmp;
struct ip *ip;
struct ip_moptions imo;
-#ifdef MROUTING
- extern struct socket *ip_mrouter;
-#endif /* MROUTING */
MGETHDR(m, M_DONTWAIT, MT_HEADER);
if (m == NULL)
Index: netinet/ip_icmp.c
===================================================================
RCS file: /home/ncvs/src/sys/netinet/ip_icmp.c,v
retrieving revision 1.96
diff -u -p -r1.96 ip_icmp.c
--- netinet/ip_icmp.c 18 Sep 2012 12:35:51 -0000 1.96
+++ netinet/ip_icmp.c 9 Apr 2013 09:46:17 -0000
@@ -125,6 +125,9 @@ void icmp_mtudisc_timeout(struct rtentry
int icmp_ratelimit(const struct in_addr *, const int, const int);
void icmp_redirect_timeout(struct rtentry *, struct rttimer *);
+/* from ip_input.c */
+extern u_char ip_protox[];
+
extern struct protosw inetsw[];
void
@@ -312,8 +315,6 @@ icmp_input(struct mbuf *m, ...)
struct in_ifaddr *ia;
void *(*ctlfunc)(int, struct sockaddr *, u_int, void *);
int code;
- extern u_char ip_protox[];
- extern int ipforwarding;
int hlen;
va_list ap;
struct rtentry *rt;
@@ -1007,7 +1008,6 @@ icmp_mtudisc_timeout(struct rtentry *rt,
if ((rt->rt_flags & (RTF_DYNAMIC | RTF_HOST)) ==
(RTF_DYNAMIC | RTF_HOST)) {
void *(*ctlfunc)(int, struct sockaddr *, u_int, void *);
- extern u_char ip_protox[];
struct sockaddr_in sa;
struct rt_addrinfo info;
Index: netinet/ip_input.c
===================================================================
RCS file: /home/ncvs/src/sys/netinet/ip_input.c,v
retrieving revision 1.206
diff -u -p -r1.206 ip_input.c
--- netinet/ip_input.c 29 Mar 2013 13:16:14 -0000 1.206
+++ netinet/ip_input.c 9 Apr 2013 09:46:17 -0000
@@ -122,12 +122,7 @@ int ip_maxqueue = 300;
int ip_frags = 0;
/* from in_pcb.c */
-extern int ipport_firstauto;
-extern int ipport_lastauto;
-extern int ipport_hifirstauto;
-extern int ipport_hilastauto;
extern struct baddynamicports baddynamicports;
-extern int la_hold_total;
int *ipctl_vars[IPCTL_MAXID] = IPCTL_VARS;
@@ -391,8 +386,6 @@ ipv4_input(struct mbuf *m)
if (IN_MULTICAST(ip->ip_dst.s_addr)) {
struct in_multi *inm;
#ifdef MROUTING
- extern struct socket *ip_mrouter;
-
if (ipmforwarding && ip_mrouter) {
if (m->m_flags & M_EXT) {
if ((m = m_pullup(m, hlen)) == NULL) {
Index: netinet/ip_ipsp.c
===================================================================
RCS file: /home/ncvs/src/sys/netinet/ip_ipsp.c,v
retrieving revision 1.186
diff -u -p -r1.186 ip_ipsp.c
--- netinet/ip_ipsp.c 28 Mar 2013 23:10:05 -0000 1.186
+++ netinet/ip_ipsp.c 9 Apr 2013 09:46:17 -0000
@@ -64,6 +64,7 @@
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <netinet/in_pcb.h>
+#include <netinet/ip_var.h>
#endif /* INET */
#ifdef INET6
@@ -102,7 +103,6 @@ extern int ipsec_esp_trans_default_level
extern int ipsec_esp_network_default_level;
extern int ipsec_ipcomp_default_level;
-extern int encdebug;
int ipsec_in_use = 0;
u_int64_t ipsec_last_added = 0;
Index: netinet/ip_output.c
===================================================================
RCS file: /home/ncvs/src/sys/netinet/ip_output.c,v
retrieving revision 1.235
diff -u -p -r1.235 ip_output.c
--- netinet/ip_output.c 6 Nov 2012 12:32:42 -0000 1.235
+++ netinet/ip_output.c 9 Apr 2013 09:46:17 -0000
@@ -523,8 +523,6 @@ reroute:
* above, will be forwarded by the ip_input() routine,
* if necessary.
*/
- extern struct socket *ip_mrouter;
-
if (ipmforwarding && ip_mrouter &&
(flags & IP_FORWARDING) == 0) {
if (ip_mforward(m, ifp) != 0) {
Index: netinet/ip_var.h
===================================================================
RCS file: /home/ncvs/src/sys/netinet/ip_var.h,v
retrieving revision 1.44
diff -u -p -r1.44 ip_var.h
--- netinet/ip_var.h 16 Jul 2012 18:05:36 -0000 1.44
+++ netinet/ip_var.h 9 Apr 2013 09:46:17 -0000
@@ -148,9 +148,25 @@ struct ipstat {
extern struct ipstat ipstat;
extern LIST_HEAD(ipqhead, ipq) ipq; /* ip reass. queue */
extern int ip_defttl; /* default IP ttl */
+#ifdef MROUTING
+extern struct socket *ip_mrouter; /* multicast routing daemon */
+#endif
extern int ip_mtudisc; /* mtu discovery */
extern u_int ip_mtudisc_timeout; /* seconds to timeout mtu discovery */
+
+extern int ipport_firstauto; /* min port for port allocation */
+extern int ipport_lastauto; /* max port for port allocation */
+extern int ipport_hifirstauto; /* min dynamic/private port number */
+extern int ipport_hilastauto; /* max dynamic/private port number */
+extern int encdebug; /* enable message reporting */
+extern int ipforwarding; /* enable IP forwarding */
+#ifdef MROUTING
+extern int ipmforwarding; /* enable multicast forwarding */
+#endif
+extern int ipmultipath; /* enable multipath routing */
+extern int la_hold_total;
+
extern struct rttimer_queue *ip_mtudisc_timeout_q;
extern struct pool ipqent_pool;
struct inpcb;
Index: netinet/ipsec_input.c
===================================================================
RCS file: /home/ncvs/src/sys/netinet/ipsec_input.c,v
retrieving revision 1.111
diff -u -p -r1.111 ipsec_input.c
--- netinet/ipsec_input.c 31 Mar 2013 00:59:52 -0000 1.111
+++ netinet/ipsec_input.c 9 Apr 2013 09:46:17 -0000
@@ -952,7 +952,6 @@ void *
ipsec_common_ctlinput(u_int rdomain, int cmd, struct sockaddr *sa,
void *v, int proto)
{
- extern u_int ip_mtudisc_timeout;
struct ip *ip = v;
int s;
Index: netinet/ipsec_output.c
===================================================================
RCS file: /home/ncvs/src/sys/netinet/ipsec_output.c,v
retrieving revision 1.47
diff -u -p -r1.47 ipsec_output.c
--- netinet/ipsec_output.c 28 Mar 2013 23:10:06 -0000 1.47
+++ netinet/ipsec_output.c 9 Apr 2013 09:46:17 -0000
@@ -375,8 +375,6 @@ ipsp_process_packet(struct mbuf *m, stru
/* Non expansion policy for IPCOMP */
if (tdb->tdb_sproto == IPPROTO_IPCOMP) {
if ((m->m_pkthdr.len - i) < tdb->tdb_compalgxform->minlen) {
- extern struct ipcompstat ipcompstat;
-
/* No need to compress, leave the packet untouched */
ipcompstat.ipcomps_minlen++;
return ipsp_process_done(m, tdb);
Index: netinet/raw_ip.c
===================================================================
RCS file: /home/ncvs/src/sys/netinet/raw_ip.c,v
retrieving revision 1.65
diff -u -p -r1.65 raw_ip.c
--- netinet/raw_ip.c 2 Apr 2013 18:27:47 -0000 1.65
+++ netinet/raw_ip.c 9 Apr 2013 09:46:17 -0000
@@ -399,9 +399,7 @@ rip_usrreq(struct socket *so, int req, s
struct inpcb *inp = sotoinpcb(so);
int error = 0;
int s;
-#ifdef MROUTING
- extern struct socket *ip_mrouter;
-#endif
+
if (req == PRU_CONTROL)
return (in_control(so, (u_long)m, (caddr_t)nam,
(struct ifnet *)control));
Index: netinet/tcp_input.c
===================================================================
RCS file: /home/ncvs/src/sys/netinet/tcp_input.c,v
retrieving revision 1.259
diff -u -p -r1.259 tcp_input.c
--- netinet/tcp_input.c 2 Apr 2013 18:27:47 -0000 1.259
+++ netinet/tcp_input.c 9 Apr 2013 09:46:17 -0000
@@ -121,8 +121,6 @@ struct tcpipv6hdr tcp_saveti6;
int tcprexmtthresh = 3;
int tcptv_keep_init = TCPTV_KEEP_INIT;
-extern u_long sb_max;
-
int tcp_rst_ppslim = 100; /* 100pps */
int tcp_rst_ppslim_count = 0;
struct timeval tcp_rst_ppslim_last;
Index: netinet/tcp_subr.c
===================================================================
RCS file: /home/ncvs/src/sys/netinet/tcp_subr.c,v
retrieving revision 1.117
diff -u -p -r1.117 tcp_subr.c
--- netinet/tcp_subr.c 2 Apr 2013 18:27:47 -0000 1.117
+++ netinet/tcp_subr.c 9 Apr 2013 09:46:17 -0000
@@ -84,6 +84,7 @@
#include <netinet/in.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
+#include <netinet/in_var.h>
#include <netinet/in_pcb.h>
#include <netinet/ip_var.h>
#include <netinet/ip_icmp.h>
@@ -97,6 +98,7 @@
#ifdef INET6
#include <netinet6/in6_var.h>
+#include <netinet6/ip6_var.h>
#include <netinet6/ip6protosw.h>
#endif /* INET6 */
@@ -137,10 +139,6 @@ int tcp_reass_limit = NMBCLUSTERS / 2; /
int tcp_sackhole_limit = 32*1024; /* hardlimit for sackhl_pool */
#endif
-#ifdef INET6
-extern int ip6_defhlim;
-#endif /* INET6 */
-
struct pool tcpcb_pool;
struct pool tcpqe_pool;
#ifdef TCP_SACK
@@ -778,7 +776,6 @@ tcp_ctlinput(int cmd, struct sockaddr *s
struct in_addr faddr;
tcp_seq seq;
u_int mtu;
- extern int inetctlerrmap[];
void (*notify)(struct inpcb *, int) = tcp_notify;
int errno;
Index: netinet/tcp_usrreq.c
===================================================================
RCS file: /home/ncvs/src/sys/netinet/tcp_usrreq.c,v
retrieving revision 1.110
diff -u -p -r1.110 tcp_usrreq.c
--- netinet/tcp_usrreq.c 24 Feb 2012 06:19:00 -0000 1.110
+++ netinet/tcp_usrreq.c 9 Apr 2013 09:46:17 -0000
@@ -100,14 +100,6 @@
#include <netinet/tcpip.h>
#include <netinet/tcp_debug.h>
-/*
- * TCP protocol interface to socket abstraction.
- */
-extern char *tcpstates[];
-extern int tcptv_keep_init;
-
-extern int tcp_rst_ppslim;
-
/* from in_pcb.c */
extern struct baddynamicports baddynamicports;
Index: netinet/tcp_var.h
===================================================================
RCS file: /home/ncvs/src/sys/netinet/tcp_var.h,v
retrieving revision 1.99
diff -u -p -r1.99 tcp_var.h
--- netinet/tcp_var.h 6 Jul 2011 23:44:20 -0000 1.99
+++ netinet/tcp_var.h 9 Apr 2013 09:46:17 -0000
@@ -538,7 +538,9 @@ extern struct inpcbtable tcbtable; /* he
extern struct tcpstat tcpstat; /* tcp statistics */
extern u_int32_t tcp_now; /* for RFC 1323 timestamps */
extern int tcp_do_rfc1323; /* enabled/disabled? */
+extern int tcptv_keep_init; /* time to keep alive the initial SYN packet */
extern int tcp_mssdflt; /* default maximum segment size */
+extern int tcp_rst_ppslim; /* maximum outgoing RST packet per second */
extern int tcp_ack_on_push; /* ACK immediately on PUSH */
#ifdef TCP_SACK
extern int tcp_do_sack; /* SACK enabled/disabled */
Index: netinet/udp_usrreq.c
===================================================================
RCS file: /home/ncvs/src/sys/netinet/udp_usrreq.c,v
retrieving revision 1.159
diff -u -p -r1.159 udp_usrreq.c
--- netinet/udp_usrreq.c 4 Apr 2013 19:23:39 -0000 1.159
+++ netinet/udp_usrreq.c 9 Apr 2013 09:46:17 -0000
@@ -99,9 +99,8 @@
#ifndef INET
#include <netinet/in.h>
#endif
+#include <netinet6/ip6_var.h>
#include <netinet6/ip6protosw.h>
-
-extern int ip6_defhlim;
#endif /* INET6 */
#include "pf.h"
@@ -905,7 +904,6 @@ udp_ctlinput(int cmd, struct sockaddr *s
struct udphdr *uhp;
struct in_addr faddr;
struct inpcb *inp;
- extern int inetctlerrmap[];
void (*notify)(struct inpcb *, int) = udp_notify;
int errno;
Index: netinet6/in6_pcb.c
===================================================================
RCS file: /home/ncvs/src/sys/netinet6/in6_pcb.c,v
retrieving revision 1.53
diff -u -p -r1.53 in6_pcb.c
--- netinet6/in6_pcb.c 28 Mar 2013 16:45:16 -0000 1.53
+++ netinet6/in6_pcb.c 9 Apr 2013 09:46:17 -0000
@@ -117,6 +117,7 @@
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <netinet/in_pcb.h>
+#include <netinet/ip_var.h>
#include <netinet6/in6_var.h>
#include <netinet/ip6.h>
@@ -133,11 +134,6 @@
*/
struct in6_addr zeroin6_addr;
-
-extern int ipport_firstauto;
-extern int ipport_lastauto;
-extern int ipport_hifirstauto;
-extern int ipport_hilastauto;
/*
* Keep separate inet6ctlerrmap, because I may remap some of these.
Index: netinet6/nd6.c
===================================================================
RCS file: /home/ncvs/src/sys/netinet6/nd6.c,v
retrieving revision 1.97
diff -u -p -r1.97 nd6.c
--- netinet6/nd6.c 25 Mar 2013 14:40:57 -0000 1.97
+++ netinet6/nd6.c 9 Apr 2013 09:46:17 -0000
@@ -103,7 +103,6 @@ void nd6_llinfo_timer(void *);
struct timeout nd6_slowtimo_ch;
struct timeout nd6_timer_ch;
-extern struct timeout in6_tmpaddrtimer_ch;
int fill_drlist(void *, size_t *, size_t);
int fill_prlist(void *, size_t *, size_t);