Skip to content

Commit 2a9e950

Browse files
committed
net: Remove __KERNEL__ cpp checks from include/net
These header files are never installed to user consumption, so any __KERNEL__ cpp checks are superfluous. Projects should also not copy these files into their userland utility sources and try to use them there. If they insist on doing so, the onus is on them to sanitize the headers as needed. Signed-off-by: David S. Miller <[email protected]>
1 parent b71d1d4 commit 2a9e950

21 files changed

+0
-73
lines changed

include/net/addrconf.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ struct prefix_info {
4242
};
4343

4444

45-
#ifdef __KERNEL__
46-
4745
#include <linux/netdevice.h>
4846
#include <net/if_inet6.h>
4947
#include <net/ipv6.h>
@@ -285,4 +283,3 @@ extern void if6_proc_exit(void);
285283
#endif
286284

287285
#endif
288-
#endif

include/net/af_rxrpc.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
#ifndef _NET_RXRPC_H
1313
#define _NET_RXRPC_H
1414

15-
#ifdef __KERNEL__
16-
1715
#include <linux/rxrpc.h>
1816

1917
struct rxrpc_call;
@@ -53,5 +51,4 @@ extern struct rxrpc_call *rxrpc_kernel_accept_call(struct socket *,
5351
unsigned long);
5452
extern int rxrpc_kernel_reject_call(struct socket *);
5553

56-
#endif /* __KERNEL__ */
5754
#endif /* _NET_RXRPC_H */

include/net/af_unix.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ struct unix_skb_parms {
4141
spin_lock_nested(&unix_sk(s)->lock, \
4242
SINGLE_DEPTH_NESTING)
4343

44-
#ifdef __KERNEL__
4544
/* The AF_UNIX socket */
4645
struct unix_sock {
4746
/* WARNING: sk has to be the first member */
@@ -72,4 +71,3 @@ static inline int unix_sysctl_register(struct net *net) { return 0; }
7271
static inline void unix_sysctl_unregister(struct net *net) {}
7372
#endif
7473
#endif
75-
#endif

include/net/atmclip.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,6 @@ struct clip_priv {
5454
};
5555

5656

57-
#ifdef __KERNEL__
5857
extern struct neigh_table *clip_tbl_hook;
59-
#endif
6058

6159
#endif

include/net/bluetooth/hci.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1067,7 +1067,6 @@ struct hci_sco_hdr {
10671067
__u8 dlen;
10681068
} __packed;
10691069

1070-
#ifdef __KERNEL__
10711070
#include <linux/skbuff.h>
10721071
static inline struct hci_event_hdr *hci_event_hdr(const struct sk_buff *skb)
10731072
{
@@ -1083,7 +1082,6 @@ static inline struct hci_sco_hdr *hci_sco_hdr(const struct sk_buff *skb)
10831082
{
10841083
return (struct hci_sco_hdr *) skb->data;
10851084
}
1086-
#endif
10871085

10881086
/* Command opcode pack/unpack */
10891087
#define hci_opcode_pack(ogf, ocf) (__u16) ((ocf & 0x03ff)|(ogf << 10))

include/net/dst.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,6 @@ struct dst_entry {
9292
};
9393
};
9494

95-
#ifdef __KERNEL__
96-
9795
extern u32 *dst_cow_metrics_generic(struct dst_entry *dst, unsigned long old);
9896
extern const u32 dst_default_metrics[RTAX_MAX];
9997

@@ -438,6 +436,5 @@ extern struct dst_entry *xfrm_lookup(struct net *net, struct dst_entry *dst_orig
438436
const struct flowi *fl, struct sock *sk,
439437
int flags);
440438
#endif
441-
#endif
442439

443440
#endif /* _NET_DST_H */

include/net/if_inet6.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@
3030
#define IF_PREFIX_ONLINK 0x01
3131
#define IF_PREFIX_AUTOCONF 0x02
3232

33-
#ifdef __KERNEL__
34-
3533
enum {
3634
INET6_IFADDR_STATE_DAD,
3735
INET6_IFADDR_STATE_POSTDAD,
@@ -303,4 +301,3 @@ static inline int ipv6_ipgre_mc_map(const struct in6_addr *addr,
303301
}
304302

305303
#endif
306-
#endif

include/net/ip6_fib.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
#ifndef _IP6_FIB_H
1414
#define _IP6_FIB_H
1515

16-
#ifdef __KERNEL__
17-
1816
#include <linux/ipv6_route.h>
1917
#include <linux/rtnetlink.h>
2018
#include <linux/spinlock.h>
@@ -240,4 +238,3 @@ static inline void fib6_rules_cleanup(void)
240238
}
241239
#endif
242240
#endif
243-
#endif

include/net/ip6_route.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ struct route_info {
2121
__u8 prefix[0]; /* 0,8 or 16 */
2222
};
2323

24-
#ifdef __KERNEL__
25-
2624
#include <net/flow.h>
2725
#include <net/ip6_fib.h>
2826
#include <net/sock.h>
@@ -193,4 +191,3 @@ static inline int ip6_skb_dst_mtu(struct sk_buff *skb)
193191
}
194192

195193
#endif
196-
#endif

include/net/ip_vs.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88

99
#include <linux/ip_vs.h> /* definitions shared with userland */
1010

11-
/* old ipvsadm versions still include this file directly */
12-
#ifdef __KERNEL__
13-
1411
#include <asm/types.h> /* for __uXX types */
1512

1613
#include <linux/sysctl.h> /* for ctl_path */
@@ -1415,6 +1412,4 @@ ip_vs_dest_conn_overhead(struct ip_vs_dest *dest)
14151412
atomic_read(&dest->inactconns);
14161413
}
14171414

1418-
#endif /* __KERNEL__ */
1419-
14201415
#endif /* _NET_IP_VS_H */

include/net/ipv6.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,9 @@
7777
/*
7878
* Addr scopes
7979
*/
80-
#ifdef __KERNEL__
8180
#define IPV6_ADDR_MC_SCOPE(a) \
8281
((a)->s6_addr[1] & 0x0f) /* nonstandard */
8382
#define __IPV6_ADDR_SCOPE_INVALID -1
84-
#endif
8583
#define IPV6_ADDR_SCOPE_NODELOCAL 0x01
8684
#define IPV6_ADDR_SCOPE_LINKLOCAL 0x02
8785
#define IPV6_ADDR_SCOPE_SITELOCAL 0x05
@@ -91,14 +89,12 @@
9189
/*
9290
* Addr flags
9391
*/
94-
#ifdef __KERNEL__
9592
#define IPV6_ADDR_MC_FLAG_TRANSIENT(a) \
9693
((a)->s6_addr[1] & 0x10)
9794
#define IPV6_ADDR_MC_FLAG_PREFIX(a) \
9895
((a)->s6_addr[1] & 0x20)
9996
#define IPV6_ADDR_MC_FLAG_RENDEZVOUS(a) \
10097
((a)->s6_addr[1] & 0x40)
101-
#endif
10298

10399
/*
104100
* fragmentation header
@@ -113,8 +109,6 @@ struct frag_hdr {
113109

114110
#define IP6_MF 0x0001
115111

116-
#ifdef __KERNEL__
117-
118112
#include <net/sock.h>
119113

120114
/* sysctls */
@@ -667,5 +661,4 @@ extern int ipv6_static_sysctl_register(void);
667661
extern void ipv6_static_sysctl_unregister(void);
668662
#endif
669663

670-
#endif /* __KERNEL__ */
671664
#endif /* _NET_IPV6_H */

include/net/ipx.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ struct ipx_route {
8080
atomic_t refcnt;
8181
};
8282

83-
#ifdef __KERNEL__
8483
struct ipx_cb {
8584
u8 ipx_tctrl;
8685
__be32 ipx_dest_net;
@@ -116,7 +115,6 @@ static inline struct ipx_sock *ipx_sk(struct sock *sk)
116115
}
117116

118117
#define IPX_SKB_CB(__skb) ((struct ipx_cb *)&((__skb)->cb[0]))
119-
#endif
120118

121119
#define IPX_MIN_EPHEMERAL_SOCKET 0x4000
122120
#define IPX_MAX_EPHEMERAL_SOCKET 0x7fff

include/net/ndisc.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ enum {
4242
#define ND_REACHABLE_TIME (30*HZ)
4343
#define ND_RETRANS_TIMER HZ
4444

45-
#ifdef __KERNEL__
46-
4745
#include <linux/compiler.h>
4846
#include <linux/icmpv6.h>
4947
#include <linux/in6.h>
@@ -156,8 +154,4 @@ static inline struct neighbour * ndisc_get_neigh(struct net_device *dev, const s
156154
return ERR_PTR(-ENODEV);
157155
}
158156

159-
160-
#endif /* __KERNEL__ */
161-
162-
163157
#endif

include/net/netevent.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
*
1111
* Changes:
1212
*/
13-
#ifdef __KERNEL__
1413

1514
struct dst_entry;
1615

@@ -29,4 +28,3 @@ extern int unregister_netevent_notifier(struct notifier_block *nb);
2928
extern int call_netevent_notifiers(unsigned long val, void *v);
3029

3130
#endif
32-
#endif

include/net/netfilter/nf_conntrack.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
#include <linux/netfilter/nf_conntrack_common.h>
1616

17-
#ifdef __KERNEL__
1817
#include <linux/bitops.h>
1918
#include <linux/compiler.h>
2019
#include <asm/atomic.h>
@@ -326,5 +325,4 @@ do { \
326325
#define MODULE_ALIAS_NFCT_HELPER(helper) \
327326
MODULE_ALIAS("nfct-helper-" helper)
328327

329-
#endif /* __KERNEL__ */
330328
#endif /* _NF_CONNTRACK_H */

include/net/netfilter/nf_conntrack_tuple.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,6 @@ struct nf_conntrack_tuple_mask {
104104
} src;
105105
};
106106

107-
#ifdef __KERNEL__
108-
109107
static inline void nf_ct_dump_tuple_ip(const struct nf_conntrack_tuple *t)
110108
{
111109
#ifdef DEBUG
@@ -148,8 +146,6 @@ struct nf_conntrack_tuple_hash {
148146
struct nf_conntrack_tuple tuple;
149147
};
150148

151-
#endif /* __KERNEL__ */
152-
153149
static inline bool __nf_ct_tuple_src_equal(const struct nf_conntrack_tuple *t1,
154150
const struct nf_conntrack_tuple *t2)
155151
{

include/net/netfilter/nf_nat.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ struct nf_nat_multi_range_compat {
4848
struct nf_nat_range range[1];
4949
};
5050

51-
#ifdef __KERNEL__
5251
#include <linux/list.h>
5352
#include <linux/netfilter/nf_conntrack_pptp.h>
5453
#include <net/netfilter/nf_conntrack_extend.h>
@@ -93,7 +92,4 @@ static inline struct nf_conn_nat *nfct_nat(const struct nf_conn *ct)
9392
#endif
9493
}
9594

96-
#else /* !__KERNEL__: iptables wants this to compile. */
97-
#define nf_nat_multi_range nf_nat_multi_range_compat
98-
#endif /*__KERNEL__*/
9995
#endif

include/net/rawv6.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
#ifndef _NET_RAWV6_H
22
#define _NET_RAWV6_H
33

4-
#ifdef __KERNEL__
5-
64
#include <net/protocol.h>
75

86
void raw6_icmp_error(struct sk_buff *, int nexthdr,
@@ -20,5 +18,3 @@ int rawv6_mh_filter_unregister(int (*filter)(struct sock *sock,
2018
#endif
2119

2220
#endif
23-
24-
#endif

include/net/route.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,6 @@
3535
#include <linux/cache.h>
3636
#include <linux/security.h>
3737

38-
#ifndef __KERNEL__
39-
#warning This file is not supposed to be used outside of kernel.
40-
#endif
41-
4238
#define RTO_ONLINK 0x01
4339

4440
#define RTO_CONN 0

include/net/transp_v6.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
* IPv6 transport protocols
88
*/
99

10-
#ifdef __KERNEL__
11-
1210
extern struct proto rawv6_prot;
1311
extern struct proto udpv6_prot;
1412
extern struct proto udplitev6_prot;
@@ -57,5 +55,3 @@ extern const struct inet_connection_sock_af_ops ipv4_specific;
5755
extern void inet6_destroy_sock(struct sock *sk);
5856

5957
#endif
60-
61-
#endif

include/net/wimax.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,6 @@
250250

251251
#ifndef __NET__WIMAX_H__
252252
#define __NET__WIMAX_H__
253-
#ifdef __KERNEL__
254253

255254
#include <linux/wimax.h>
256255
#include <net/genetlink.h>
@@ -518,8 +517,4 @@ extern ssize_t wimax_msg_len(struct sk_buff *);
518517
extern int wimax_rfkill(struct wimax_dev *, enum wimax_rf_state);
519518
extern int wimax_reset(struct wimax_dev *);
520519

521-
#else
522-
/* You might be looking for linux/wimax.h */
523-
#error This file should not be included from user space.
524-
#endif /* #ifdef __KERNEL__ */
525520
#endif /* #ifndef __NET__WIMAX_H__ */

0 commit comments

Comments
 (0)