Implement dumping udp sockets via sock_diag netlink
Subsystems (13)
cover Implement dumping udp sockets via sock_diag netlink
Hi!
This is an extension of inet_diag module and the new udp_diag one. Plus the patch for iproute's ss to dump udp sockets via netlink (applies on top of previous patch for new NETLINK_SOCK_DIAG API [1]).
The overall idea is:
Patch the inet_diag module so that the protocol level handlers are called indirectly from the very beginning, not just for getting the tcp_info bits. Implement the udp_diag module that provides callbacks for IPPROTO_UDP and IPPROTO_UDPLITE protocols.
The existing inet request packet (inet_diag_req) format used to request for TCP/DCCP sockets is used for UDP socket as well, although not all the state bits matter for UDP.
When sending back the reply the existing format (inet_diag_message) is used as well. Some bits on this struct are meaningless for UDP, but I hope that setting these to 0 and wasting some space on reply skb worth the saved amount of new code on both -- the kernel side and the userspace side (i.e. ss tool). The data that is stored in an nl attribute but doesn't exist for UDP is just not provided.
PATCH 1/13 inet_diag: Remove indirect sizeof from inet diag handlers
There's an info_size value stored on inet_diag_handler, but for existing code this value is effectively constant, so just use sizeof(struct tcp_info) where required.
--- include/linux/inet_diag.h | 1 - net/dccp/diag.c | 1 - net/ipv4/inet_diag.c | 5 ++--- net/ipv4/tcp_diag.c | 1 - 4 files changed, 2 insertions(+), 6 deletions(-)
include/linux/inet_diag.h +0 -1
@@ -141,7 +141,6 @@ struct inet_diag_handler {void (*idiag_get_info)(struct sock *sk,struct inet_diag_msg *r,void *info); -__u16 idiag_info_size;__u16 idiag_type; };
net/dccp/diag.c +0 -1
@@ -52,7 +52,6 @@ static const struct inet_diag_handler dccp_diag_handler = { .idiag_hashinfo = &dccp_hashinfo, .idiag_get_info = dccp_diag_get_info, .idiag_type = IPPROTO_DCCP, - .idiag_info_size = sizeof(struct tcp_info), };static int __init dccp_diag_init (void )
net/ipv4/inet_diag.c +2 -3
@@ -98,8 +98,7 @@ static int inet_csk_diag_fill(struct sock *sk, minfo =INET_DIAG_PUT (skb,INET_DIAG_MEMINFO ,sizeof (*minfo));if (ext & (1 << (INET_DIAG_INFO -1 ))) - info =INET_DIAG_PUT (skb,INET_DIAG_INFO , - handler->idiag_info_size); + info =INET_DIAG_PUT (skb,INET_DIAG_INFO ,sizeof (struct tcp_info ));if ((ext & (1 << (INET_DIAG_CONG -1 ))) && icsk->icsk_ca_ops) {const size_t len =strlen (icsk->icsk_ca_ops->name);
@@ -299,7 +298,7 @@ static int inet_diag_get_exact(struct sk_buff *in_skb, err = -ENOMEM ; rep =alloc_skb (NLMSG_SPACE ((sizeof (struct inet_diag_msg ) +sizeof (struct inet_diag_meminfo ) + - handler->idiag_info_size +64 )), +sizeof (struct tcp_info ) +64 )),GFP_KERNEL );if (!rep) goto out;
net/ipv4/tcp_diag.c +0 -1
@@ -38,7 +38,6 @@ static const struct inet_diag_handler tcp_diag_handler = { .idiag_hashinfo = &tcp_hashinfo, .idiag_get_info = tcp_diag_get_info, .idiag_type = IPPROTO_TCP, - .idiag_info_size = sizeof(struct tcp_info), };static int __init tcp_diag_init (void )
Signature · 1 line
1.5.5.6
PATCH 2/13 inet_diag: Reduce the number of args for bytecode run routine
In reply to Pavel Emelyanov--- net/ipv4/inet_diag.c | 14 ++++++++------ 1 files changed, 8 insertions(+), 6 deletions(-)
net/ipv4/inet_diag.c +8 -6
@@ -355,9 +355,12 @@ static int bitstring_match(const __be32 *a1, const __be32 *a2, int bits) } -static int inet_diag_bc_run (const void *bc,int len, -const struct inet_diag_entry *entry) +static int inet_diag_bc_run (const struct nlattr *_bc, +const struct inet_diag_entry *entry) { +const void *bc =nla_data (_bc); +int len =nla_len (_bc); +while (len >0 ) {int yes =1 ;const struct inet_diag_bc_op *op = bc;
@@ -512,7 +515,7 @@ static int inet_csk_diag_dump(struct sock *sk, entry.dport =ntohs (inet->inet_dport); entry.userlocks = sk->sk_userlocks; -if (!inet_diag_bc_run (nla_data (bc),nla_len (bc), &entry)) +if (!inet_diag_bc_run (bc, &entry))return 0 ; }
@@ -547,7 +550,7 @@ static int inet_twsk_diag_dump(struct inet_timewait_sock *tw, entry.dport =ntohs (tw->tw_dport); entry.userlocks =0 ; -if (!inet_diag_bc_run (nla_data (bc),nla_len (bc), &entry)) +if (!inet_diag_bc_run (bc, &entry))return 0 ; }
@@ -668,8 +671,7 @@ static int inet_diag_dump_reqs(struct sk_buff *skb, struct sock *sk, &ireq->rmt_addr; entry.dport =ntohs (ireq->rmt_port); -if (!inet_diag_bc_run (nla_data (bc), -nla_len (bc), &entry)) +if (!inet_diag_bc_run (bc, &entry))continue ; }
Signature · 1 line
1.5.5.6
PATCH 3/13 inet_diag: Export inet diag cookie checking routine
In reply to Pavel EmelyanovThe netlink diag susbsys stores sk address bits in the nl message as a "cookie" and uses one when dumps details about particular socket.
The same will be required for udp diag module, so introduce a heler in inet_diag module
--- include/linux/inet_diag.h | 2 ++ net/ipv4/inet_diag.c | 19 ++++++++++++++----- 2 files changed, 16 insertions(+), 5 deletions(-)
include/linux/inet_diag.h +2 -0
@@ -144,6 +144,8 @@ struct inet_diag_handler { __u16 idiag_type; }; +int inet_diag_check_cookie (struct sock *sk,struct inet_diag_req *req); +extern int inet_diag_register (const struct inet_diag_handler *handler);extern void inet_diag_unregister (const struct inet_diag_handler *handler);#endif /* __KERNEL__ */
net/ipv4/inet_diag.c +14 -5
@@ -246,6 +246,18 @@ static int sk_diag_fill(struct sock *sk, struct sk_buff *skb,return inet_csk_diag_fill (sk, skb, r, pid, seq, nlmsg_flags, unlh); } +int inet_diag_check_cookie (struct sock *sk,struct inet_diag_req *req) +{ +if ((req->id.idiag_cookie[0 ] !=INET_DIAG_NOCOOKIE || + req->id.idiag_cookie[1 ] !=INET_DIAG_NOCOOKIE ) && + ((u32 )(unsigned long )sk != req->id.idiag_cookie[0 ] || + (u32)((((unsigned long )sk) >>31 ) >>1 ) != req->id.idiag_cookie[1 ])) +return -ESTALE ; +else +return 0 ; +} +EXPORT_SYMBOL_GPL (inet_diag_check_cookie); +static int inet_diag_get_exact (struct sk_buff *in_skb,const struct nlmsghdr *nlh,struct inet_diag_req *req)
@@ -288,11 +300,8 @@ static int inet_diag_get_exact(struct sk_buff *in_skb,if (sk ==NULL ) goto unlock; - err = -ESTALE ; -if ((req->id.idiag_cookie[0 ] !=INET_DIAG_NOCOOKIE || - req->id.idiag_cookie[1 ] !=INET_DIAG_NOCOOKIE ) && - ((u32 )(unsigned long )sk != req->id.idiag_cookie[0 ] || - (u32)((((unsigned long )sk) >>31 ) >>1 ) != req->id.idiag_cookie[1 ])) + err =inet_diag_check_cookie (sk, req); +if (err) goto out; err = -ENOMEM ;
Signature · 1 line
1.5.5.6
PATCH 4/13 inet_diag: Split inet_diag_get_exact into parts
In reply to Pavel EmelyanovThe 1st part locks the inet handler and the 2nd one dump the inet connection sock.
In the next patches the 1st part will be generalized to call the socket dumping routine indirectly (i.e. TCP/UDP/DCCP) and the 2nd part will be used by TCP and DCCP handlers.
--- net/ipv4/inet_diag.c | 38 ++++++++++++++++++++++---------------- 1 files changed, 22 insertions(+), 16 deletions(-)
net/ipv4/inet_diag.c +22 -16
@@ -258,25 +258,14 @@ int inet_diag_check_cookie(struct sock *sk, struct inet_diag_req *req) }EXPORT_SYMBOL_GPL (inet_diag_check_cookie); -static int inet_diag_get_exact (struct sk_buff *in_skb, -const struct nlmsghdr *nlh, -struct inet_diag_req *req) +static int inet_diag_dump_one_icsk (struct inet_hashinfo *hashinfo,struct sk_buff *in_skb, +const struct nlmsghdr *nlh,struct inet_diag_req *req) {int err;struct sock *sk;struct sk_buff *rep; -struct inet_hashinfo *hashinfo; -const struct inet_diag_handler *handler; - handler =inet_diag_lock_handler (req->sdiag_protocol); -if (IS_ERR (handler)) { - err =PTR_ERR (handler); - goto unlock; - } - - hashinfo = handler->idiag_hashinfo; err = -EINVAL ; -if (req->sdiag_family ==AF_INET ) { sk = inet_lookup(&init_net, hashinfo, req->id.idiag_dst[0], req->id.idiag_dport, req->id.idiag_src[0],
@@ -293,12 +282,12 @@ static int inet_diag_get_exact(struct sk_buff *in_skb, }#endif else { - goto unlock; + goto out_nosk; } err = -ENOENT ;if (sk ==NULL ) - goto unlock; + goto out_nosk; err =inet_diag_check_cookie (sk, req);if (err)
@@ -332,8 +321,25 @@ out:else sock_put (sk); } -unlock: +out_nosk: +return err; +} + +static int inet_diag_get_exact (struct sk_buff *in_skb, +const struct nlmsghdr *nlh, +struct inet_diag_req *req) +{ +const struct inet_diag_handler *handler; +int err; + + handler =inet_diag_lock_handler (req->sdiag_protocol); +if (IS_ERR (handler)) + err =PTR_ERR (handler); +else + err =inet_diag_dump_one_icsk (handler->idiag_hashinfo, + in_skb, nlh, req);inet_diag_unlock_handler (handler); +return err; }
Signature · 1 line
1.5.5.6
PATCH 5/13 inet_diag: Split inet_diag_get_exact into parts
In reply to Pavel EmelyanovSimilar to previous patch: the 1st part locks the inet handler and will get generalized and the 2nd one dumps icsk-s and will be used by TCP and DCCP handlers.
--- net/ipv4/inet_diag.c | 28 ++++++++++++++++------------ 1 files changed, 16 insertions(+), 12 deletions(-)
net/ipv4/inet_diag.c +16 -12
@@ -709,19 +709,11 @@ out:return err; } -static int __inet_diag_dump (struct sk_buff *skb,struct netlink_callback *cb, -struct inet_diag_req *r,struct nlattr *bc) +static void inet_diag_dump_icsk (struct inet_hashinfo *hashinfo,struct sk_buff *skb, +struct netlink_callback *cb,struct inet_diag_req *r,struct nlattr *bc) {int i, num;int s_i, s_num; -const struct inet_diag_handler *handler; -struct inet_hashinfo *hashinfo; - - handler =inet_diag_lock_handler (r->sdiag_protocol); -if (IS_ERR (handler)) - goto unlock; - - hashinfo = handler->idiag_hashinfo; s_i = cb->args[1 ]; s_num = num = cb->args[2 ];
@@ -790,7 +782,7 @@ skip_listen_ht: }if (!(r->idiag_states & ~(TCPF_LISTEN |TCPF_SYN_RECV ))) - goto unlock; + goto out;for (i = s_i; i <= hashinfo->ehash_mask; i++) {struct inet_ehash_bucket *head = &hashinfo->ehash[i];
@@ -863,8 +855,20 @@ next_dying: done: cb->args[1 ] = i; cb->args[2 ] = num; -unlock: +out: + ; +} + +static int __inet_diag_dump (struct sk_buff *skb,struct netlink_callback *cb, +struct inet_diag_req *r,struct nlattr *bc) +{ +const struct inet_diag_handler *handler; + + handler =inet_diag_lock_handler (r->sdiag_protocol); +if (!IS_ERR (handler)) +inet_diag_dump_icsk (handler->idiag_hashinfo, skb, cb, r, bc);inet_diag_unlock_handler (handler); +return skb->len; }
Signature · 1 line
1.5.5.6
PATCH 6/13 inet_diag: Introduce the byte-code run on an inet socket
In reply to Pavel EmelyanovThe upcoming UDP module will require exactly this ability, so just move the existing code to provide one.
--- include/linux/inet_diag.h | 2 + net/ipv4/inet_diag.c | 55 +++++++++++++++++++++++++------------------- 2 files changed, 33 insertions(+), 24 deletions(-)
include/linux/inet_diag.h +2 -0
@@ -135,6 +135,7 @@ struct tcpvegas_info { #ifdef __KERNEL__ struct sock; struct inet_hashinfo; +struct nlattr; struct inet_diag_handler { struct inet_hashinfo *idiag_hashinfo;
@@ -144,6 +145,7 @@ struct inet_diag_handler {__u16 idiag_type; }; +int inet_diag_bc_sk (const struct nlattr *_bc,struct sock *sk);int inet_diag_check_cookie (struct sock *sk,struct inet_diag_req *req);extern int inet_diag_register (const struct inet_diag_handler *handler);
net/ipv4/inet_diag.c +31 -24
67 lines not on this page · raw message
Signature · 1 line
1.5.5.6
PATCH 7/13 inet_diag: Introduce the inet socket dumping routine
In reply to Pavel EmelyanovThe existing inet_csk_diag_fill dumps the inet connection sock info into the netlink inet_diag_message. Prepare this routine to be able to dump only the inet_sock part of a socket if the icsk part is missing.
This will be used by UDP diag module when dumping UDP sockets.
--- include/linux/inet_diag.h | 7 ++++++ net/ipv4/inet_diag.c | 53 ++++++++++++++++++++++++++++---------------- 2 files changed, 41 insertions(+), 19 deletions(-)
include/linux/inet_diag.h +7 -0
@@ -136,6 +136,8 @@ struct tcpvegas_info {struct sock ;struct inet_hashinfo ;struct nlattr ; +struct nlmsghdr ; +struct sk_buff ;struct inet_diag_handler {struct inet_hashinfo *idiag_hashinfo;
@@ -145,6 +147,11 @@ struct inet_diag_handler {__u16 idiag_type; }; +struct inet_connection_sock ; +int inet_sk_diag_fill (struct sock *sk,struct inet_connection_sock *icsk, +struct sk_buff *skb,struct inet_diag_req *req, +u32 pid,u32 seq,u16 nlmsg_flags, +const struct nlmsghdr *unlh);int inet_diag_bc_sk (const struct nlattr *_bc,struct sock *sk);int inet_diag_check_cookie (struct sock *sk,struct inet_diag_req *req);
net/ipv4/inet_diag.c +34 -19
95 lines not on this page · raw message
Signature · 1 line
1.5.5.6
PATCH 8/13 inet_diag: Generalize inet_diag dump and get_exact calls
In reply to Pavel EmelyanovIntroduce two callbacks in inet_diag_handler -- one for dumping all sockets (with filters) and the other one for dumping a single sk.
Replace direct calls to icsk handlers with indirect calls to callbacks provided by handlers.
Make existing TCP and DCCP handlers use provided helpers for icsk-s.
The UDP diag module will provide its own.
--- include/linux/inet_diag.h | 18 +++++++++++++++++- net/dccp/diag.c | 15 ++++++++++++++- net/ipv4/inet_diag.c | 11 ++++++----- net/ipv4/tcp_diag.c | 15 ++++++++++++++- 4 files changed, 51 insertions(+), 8 deletions(-)
include/linux/inet_diag.h +17 -1
@@ -138,9 +138,18 @@ struct inet_hashinfo;struct nlattr ;struct nlmsghdr ;struct sk_buff ; +struct netlink_callback ;struct inet_diag_handler { -struct inet_hashinfo *idiag_hashinfo; +void (*dump)(struct sk_buff *skb, +struct netlink_callback *cb, +struct inet_diag_req *r, +struct nlattr *bc); + +int (*dump_one)(struct sk_buff *in_skb, +const struct nlmsghdr *nlh, +struct inet_diag_req *req); +void (*idiag_get_info)(struct sock *sk,struct inet_diag_msg *r,void *info);
@@ -152,6 +161,13 @@ int inet_sk_diag_fill(struct sock *sk, struct inet_connection_sock *icsk, struct sk_buff *skb, struct inet_diag_req *req, u32 pid, u32 seq, u16 nlmsg_flags, const struct nlmsghdr *unlh); +void inet_diag_dump_icsk (struct inet_hashinfo *h,struct sk_buff *skb, +struct netlink_callback *cb,struct inet_diag_req *r, +struct nlattr *bc); +int inet_diag_dump_one_icsk (struct inet_hashinfo *hashinfo, +struct sk_buff *in_skb,const struct nlmsghdr *nlh, +struct inet_diag_req *req); +int inet_diag_bc_sk (const struct nlattr *_bc,struct sock *sk);int inet_diag_check_cookie (struct sock *sk,struct inet_diag_req *req);
net/dccp/diag.c +14 -1
@@ -48,8 +48,21 @@ static void dccp_diag_get_info(struct sock *sk, struct inet_diag_msg *r,dccp_get_info (sk, _info); } +static void dccp_diag_dump (struct sk_buff *skb,struct netlink_callback *cb, +struct inet_diag_req *r,struct nlattr *bc) +{ +inet_diag_dump_icsk (&dccp_hashinfo, skb, cb, r, bc); +} + +static int dccp_diag_dump_one (struct sk_buff *in_skb,const struct nlmsghdr *nlh, +struct inet_diag_req *req) +{ +return inet_diag_dump_one_icsk (&dccp_hashinfo, in_skb, nlh, req); +} +static const struct inet_diag_handler dccp_diag_handler = { - .idiag_hashinfo = &dccp_hashinfo, + .dump = dccp_diag_dump, + .dump_one = dccp_diag_dump_one, .idiag_get_info = dccp_diag_get_info, .idiag_type =IPPROTO_DCCP , };
net/ipv4/inet_diag.c +6 -5
@@ -273,7 +273,7 @@ int inet_diag_check_cookie(struct sock *sk, struct inet_diag_req *req) }EXPORT_SYMBOL_GPL (inet_diag_check_cookie); -static int inet_diag_dump_one_icsk (struct inet_hashinfo *hashinfo,struct sk_buff *in_skb, +int inet_diag_dump_one_icsk (struct inet_hashinfo *hashinfo,struct sk_buff *in_skb,const struct nlmsghdr *nlh,struct inet_diag_req *req) {int err;
@@ -339,6 +339,7 @@ out: out_nosk:return err; } +EXPORT_SYMBOL_GPL (inet_diag_dump_one_icsk); static int inet_diag_get_exact(struct sk_buff *in_skb, const struct nlmsghdr *nlh,
@@ -351,8 +352,7 @@ static int inet_diag_get_exact(struct sk_buff *in_skb,if (IS_ERR (handler)) err =PTR_ERR (handler);else - err =inet_diag_dump_one_icsk (handler->idiag_hashinfo, - in_skb, nlh, req); + err = handler->dump_one (in_skb, nlh, req);inet_diag_unlock_handler (handler);return err;
@@ -731,7 +731,7 @@ out:return err; } -static void inet_diag_dump_icsk (struct inet_hashinfo *hashinfo,struct sk_buff *skb, +void inet_diag_dump_icsk (struct inet_hashinfo *hashinfo,struct sk_buff *skb,struct netlink_callback *cb,struct inet_diag_req *r,struct nlattr *bc) {int i, num;
@@ -880,6 +880,7 @@ done: out: ; } +EXPORT_SYMBOL_GPL (inet_diag_dump_icsk);static int __inet_diag_dump (struct sk_buff *skb,struct netlink_callback *cb,struct inet_diag_req *r,struct nlattr *bc)
@@ -888,7 +889,7 @@ static int __inet_diag_dump(struct sk_buff *skb, struct netlink_callback *cb, handler =inet_diag_lock_handler (r->sdiag_protocol);if (!IS_ERR (handler)) -inet_diag_dump_icsk (handler->idiag_hashinfo, skb, cb, r, bc); + handler->dump (skb, cb, r, bc);inet_diag_unlock_handler (handler);return skb->len;
net/ipv4/tcp_diag.c +14 -1
@@ -34,8 +34,21 @@ static void tcp_diag_get_info(struct sock *sk, struct inet_diag_msg *r,tcp_get_info (sk, info); } +static void tcp_diag_dump (struct sk_buff *skb,struct netlink_callback *cb, +struct inet_diag_req *r,struct nlattr *bc) +{ +inet_diag_dump_icsk (&tcp_hashinfo, skb, cb, r, bc); +} + +static int tcp_diag_dump_one (struct sk_buff *in_skb,const struct nlmsghdr *nlh, +struct inet_diag_req *req) +{ +return inet_diag_dump_one_icsk (&tcp_hashinfo, in_skb, nlh, req); +} +static const struct inet_diag_handler tcp_diag_handler = { - .idiag_hashinfo = &tcp_hashinfo, + .dump = tcp_diag_dump, + .dump_one = tcp_diag_dump_one, .idiag_get_info = tcp_diag_get_info, .idiag_type =IPPROTO_TCP , };
Signature · 1 line
1.5.5.6
PATCH 9/13 udp: Export code sk lookup routines
In reply to Pavel EmelyanovThe UDP diag get_exact handler will require them to find a socket by provided net, [sd]addr-s, [sd]ports and device.
--- include/net/udp.h | 6 ++++++ net/ipv4/udp.c | 3 ++- net/ipv6/udp.c | 3 ++- 3 files changed, 10 insertions(+), 2 deletions(-)
include/net/udp.h +6 -0
@@ -194,9 +194,15 @@ extern int udp_lib_setsockopt(struct sock *sk, int level, int optname,extern struct sock *udp4_lib_lookup (struct net *net,__be32 saddr,__be16 sport,__be32 daddr,__be16 dport,int dif); +extern struct sock *__udp4_lib_lookup (struct net *net,__be32 saddr,__be16 sport, +__be32 daddr,__be16 dport, +int dif,struct udp_table *tbl);extern struct sock *udp6_lib_lookup (struct net *net,const struct in6_addr *saddr,__be16 sport,const struct in6_addr *daddr,__be16 dport,int dif); +extern struct sock *__udp6_lib_lookup (struct net *net,const struct in6_addr *saddr,__be16 sport, +const struct in6_addr *daddr,__be16 dport, +int dif,struct udp_table *tbl);/* * SNMP statistics for UDP and UDP-Lite
net/ipv4/udp.c +2 -1
@@ -445,7 +445,7 @@ exact_match:/* UDP is nearly always wildcards out the wazoo, it makes no sense to try * harder than this. -DaveM */ -static struct sock *__udp4_lib_lookup (struct net *net,__be32 saddr, +struct sock *__udp4_lib_lookup (struct net *net,__be32 saddr,__be16 sport,__be32 daddr,__be16 dport,int dif,struct udp_table *udptable) {
@@ -512,6 +512,7 @@ begin:rcu_read_unlock ();return result; } +EXPORT_SYMBOL_GPL (__udp4_lib_lookup); static inline struct sock *__udp4_lib_lookup_skb(struct sk_buff *skb, __be16 sport, __be16 dport,
net/ipv6/udp.c +2 -1
@@ -238,7 +238,7 @@ exact_match:return result; } -static struct sock *__udp6_lib_lookup (struct net *net, +struct sock *__udp6_lib_lookup (struct net *net,const struct in6_addr *saddr,__be16 sport,const struct in6_addr *daddr,__be16 dport,int dif,struct udp_table *udptable)
@@ -305,6 +305,7 @@ begin:rcu_read_unlock ();return result; } +EXPORT_SYMBOL_GPL (__udp6_lib_lookup); static struct sock *__udp6_lib_lookup_skb(struct sk_buff *skb, __be16 sport, __be16 dport,
Signature · 1 line
1.5.5.6
PATCH 10/13 udp_diag: Basic skeleton
In reply to Pavel EmelyanovIntroduce the transport level diag handler module for UDP (and UDP-lite) sockets and register (empty for now) callbacks in the inet_diag module.
--- net/ipv4/udp_diag.c | 96 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 96 insertions(+), 0 deletions(-) create mode 100644 net/ipv4/udp_diag.c
net/ipv4/udp_diag.c new file +96 -0
@@ -0,0 +1,96 @@ +/* +* udp_diag.c Module for monitoring UDP transport protocols sockets. +* +* Authors: Pavel Emelyanov, <[email protected]> +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version +* 2 of the License, or (at your option) any later version. +*/ + + +#include <linux/module.h> +#include <linux/inet_diag.h> +#include <linux/udp.h> +#include <net/udp.h> +#include <net/udplite.h> +#include <linux/inet_diag.h> +#include <linux/sock_diag.h> + +static int udp_dump_one (struct udp_table *tbl,struct sk_buff *in_skb, +const struct nlmsghdr *nlh,struct inet_diag_req *req) +{ +return 0 ; +} + +static void udp_dump (struct udp_table *table,struct sk_buff *skb,struct netlink_callback *cb, +struct inet_diag_req *r,struct nlattr *bc) +{ +} + +static void udp_diag_dump (struct sk_buff *skb,struct netlink_callback *cb, +struct inet_diag_req *r,struct nlattr *bc) +{ +udp_dump (&udp_table, skb, cb, r, bc); +} + +static int udp_diag_dump_one (struct sk_buff *in_skb,const struct nlmsghdr *nlh, +struct inet_diag_req *req) +{ +return udp_dump_one (&udp_table, in_skb, nlh, req); +} + +static const struct inet_diag_handler udp_diag_handler = { + .dump = udp_diag_dump, + .dump_one = udp_diag_dump_one, + .idiag_type =IPPROTO_UDP , +}; + +static void udplite_diag_dump (struct sk_buff *skb,struct netlink_callback *cb, +struct inet_diag_req *r,struct nlattr *bc) +{ +udp_dump (&udplite_table, skb, cb, r, bc); +} + +static int udplite_diag_dump_one (struct sk_buff *in_skb,const struct nlmsghdr *nlh, +struct inet_diag_req *req) +{ +return udp_dump_one (&udplite_table, in_skb, nlh, req); +} + +static const struct inet_diag_handler udplite_diag_handler = { + .dump = udplite_diag_dump, + .dump_one = udplite_diag_dump_one, + .idiag_type =IPPROTO_UDPLITE , +}; + +static int __init udp_diag_init (void ) +{ +int err; + + err =inet_diag_register (&udp_diag_handler); +if (err) + goto out; + err =inet_diag_register (&udplite_diag_handler); +if (err) + goto out_lite; +out: +return err; +out_lite: +inet_diag_unregister (&udp_diag_handler); + goto out; +} + +static void __exit udp_diag_exit(void) +{ +inet_diag_unregister (&udplite_diag_handler); +inet_diag_unregister (&udp_diag_handler); +} + +module_init (udp_diag_init); +module_exit (udp_diag_exit); +MODULE_LICENSE ("GPL" ); +MODULE_ALIAS_NET_PF_PROTO_TYPE (PF_NETLINK ,NETLINK_SOCK_DIAG ,17 ); +MODULE_ALIAS_NET_PF_PROTO_TYPE (PF_NETLINK ,NETLINK_SOCK_DIAG ,136 ); +
Signature · 1 line
1.5.5.6
PATCH 11/13 udp_diag: Implement the get_exact dumping functionality
In reply to Pavel EmelyanovDo the same as TCP does -- lookup a socket in the given udp_table, check cookie, fill the reply message with existing inet socket dumping helper and send one back.
--- net/ipv4/udp_diag.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 51 insertions(+), 1 deletions(-)
net/ipv4/udp_diag.c +51 -1
@@ -21,7 +21,57 @@static int udp_dump_one (struct udp_table *tbl,struct sk_buff *in_skb,const struct nlmsghdr *nlh,struct inet_diag_req *req) { -return 0 ; +int err = -EINVAL ; +struct sock *sk; +struct sk_buff *rep; + +if (req->sdiag_family ==AF_INET ) + sk =__udp4_lib_lookup (&init_net, + req->id.idiag_src[0 ], req->id.idiag_sport, + req->id.idiag_dst[0 ], req->id.idiag_dport, + req->id.idiag_if, tbl); +else if (req->sdiag_family ==AF_INET6 ) + sk =__udp6_lib_lookup (&init_net, + (struct in6_addr *)req->id.idiag_src, + req->id.idiag_sport, + (struct in6_addr *)req->id.idiag_dst, + req->id.idiag_dport, + req->id.idiag_if, tbl); +else + goto out_nosk; + + err = -ENOENT ; +if (sk ==NULL ) + goto out_nosk; + + err =inet_diag_check_cookie (sk, req); +if (err) + goto out; + + err = -ENOMEM ; + rep =alloc_skb (NLMSG_SPACE ((sizeof (struct inet_diag_msg ) + +sizeof (struct inet_diag_meminfo ) + +64 )),GFP_KERNEL ); +if (!rep) + goto out; + + err =inet_sk_diag_fill (sk,NULL , rep, req, +NETLINK_CB (in_skb).pid, + nlh->nlmsg_seq,0 , nlh); +if (err <0 ) { +WARN_ON (err == -EMSGSIZE ); +kfree_skb (rep); + goto out; + } + err =netlink_unicast (sock_diag_nlsk, rep,NETLINK_CB (in_skb).pid, +MSG_DONTWAIT ); +if (err >0 ) + err =0 ; +out: +if (sk) +sock_put (sk); +out_nosk: +return err; } static void udp_dump(struct udp_table *table, struct sk_buff *skb, struct netlink_callback *cb,
Signature · 1 line
1.5.5.6
Re: [PATCH 11/13] udp_diag: Implement the get_exact dumping functionality
Quoted 10 lines · Pavel Emelyanov
Do the same as TCP does -- lookup a socket in the given
udp_table, check cookie, fill the reply message with existing inet socket dumping helper and send one back.Signed-off-by Pavel Emelyanov <[email protected]>net/ipv4/udp_diag.c +4
-0+ +if (req->sdiag_family ==AF_INET ) + sk = __udp4_lib_lookup(&init_net, + req->id.idiag_src[0], req->id.idiag_sport,
net/ipv4/udp_diag.c line 40
Quoted 10 lines
net/ipv4/udp_diag.c +10
-0+ req->id.idiag_dst[0 ], req->id.idiag_dport, + req->id.idiag_if, tbl); + else if (req->sdiag_family == AF_INET6) + sk =__udp6_lib_lookup (&init_net, + (struct in6_addr *)req->id.idiag_src, + req->id.idiag_sport, + (struct in6_addr *)req->id.idiag_dst, + req->id.idiag_dport, + req->id.idiag_if, tbl); + else
OK, but what happens if IPv6 is a module ?
LD .tmp_vmlinux1net/built-in.o: In function `udp_dump_one':
udp_diag.c:(.text+0xa2b40): undefined reference to `__udp6_lib_lookup'
make: *** [.tmp_vmlinux1] Erreur 1
Re: [PATCH 11/13] udp_diag: Implement the get_exact dumping functionality
Quoted 7 lines · Eric Dumazet
Quoted 5 lines · Pavel Emelyanov
Do the same as TCP does -- lookup a socket in the given
udp_table, check cookie, fill the reply message with existing inet socket dumping helper and send one back.Signed-off-by Pavel Emelyanov <[email protected]>
Quoted 16 lines
Quoted 4 lines
net/ipv4/udp_diag.c +4
-0+ +if (req->sdiag_family ==AF_INET ) + sk = __udp4_lib_lookup(&init_net, + req->id.idiag_src[0], req->id.idiag_sport,net/ipv4/udp_diag.c line 40
Quoted 10 lines
net/ipv4/udp_diag.c +10
-0+ req->id.idiag_dst[0 ], req->id.idiag_dport, + req->id.idiag_if, tbl); + else if (req->sdiag_family == AF_INET6) + sk =__udp6_lib_lookup (&init_net, + (struct in6_addr *)req->id.idiag_src, + req->id.idiag_sport, + (struct in6_addr *)req->id.idiag_dst, + req->id.idiag_dport, + req->id.idiag_if, tbl); + elseOK, but what happens if IPv6 is a module ?
And the udp_diag is built-in, right?
Quoted 4 lines
LD .tmp_vmlinux1
net/built-in.o: In function `udp_dump_one':
udp_diag.c:(.text+0xa2b40): undefined reference to `__udp6_lib_lookup'
make: *** [.tmp_vmlinux1] Erreur 1
Crap :( I suppose the Kconfig rule should be fixed, I will try to provide a fix...
Thanks,
Pavel
PATCH 1/2 udp_diag: Make it module when ipv6 is a module
Eric Dumazet reported, that when inet_diag is built-in the udp_diag also goes built-in and when ipv6 is a module the udp6 lookup symbol is not found.
LD .tmp_vmlinux1net/built-in.o: In function `udp_dump_one':
udp_diag.c:(.text+0xa2b40): undefined reference to `__udp6_lib_lookup'
make: *** [.tmp_vmlinux1] Erreur 1
Fix this by making udp diag build mode depend on both -- inet diag and ipv6.
---
net/ipv4/Kconfig +1 -1
@@ -411,7 +411,7 @@ config INET_TCP_DIAG config INET_UDP_DIAG depends on INET_DIAG - def_tristate INET_DIAG + def_tristate INET_DIAG && IPV6 menuconfig TCP_CONG_ADVANCED bool "TCP: advanced congestion control"
PATCH 2/2 udp_diag: Fix the !ipv6 case
Wrap the udp6 lookup into the proper ifdef-s.
---
net/ipv4/udp_diag.c +2 -0
@@ -41,6 +41,7 @@ static int udp_dump_one(struct udp_table *tbl, struct sk_buff *in_skb, req->id.idiag_src[0 ], req->id.idiag_sport, req->id.idiag_dst[0 ], req->id.idiag_dport, req->id.idiag_if, tbl); +#if defined(CONFIG_IPV6 ) || defined (CONFIG_IPV6_MODULE ) else if (req->sdiag_family == AF_INET6) sk = __udp6_lib_lookup(&init_net, (struct in6_addr *)req->id.idiag_src,
@@ -48,6 +49,7 @@ static int udp_dump_one(struct udp_table *tbl, struct sk_buff *in_skb, (struct in6_addr *)req->id.idiag_dst, req->id.idiag_dport, req->id.idiag_if, tbl); +#endif else goto out_nosk;
Re: [PATCH 2/2] udp_diag: Fix the !ipv6 case
Quoted 11 lines · Pavel Emelyanov
Wrap the udp6 lookup into the proper ifdef-s.
Signed-off-by Pavel Emelyanov <[email protected]>---
net/ipv4/udp_diag.c +0
-0
net/ipv4/udp_diag.c static int udp_dump_one(struct udp_table *tbl, struct sk_buff *in_skb, · line 44
Quoted 4 lines
net/ipv4/udp_diag.c +1
-0@@ -41,6 +41,7 @@ static int udp_dump_one(struct udp_table *tbl, struct sk_buff *in_skb, req->id.idiag_src[0 ], req->id.idiag_sport, req->id.idiag_dst[0 ], req->id.idiag_dport, req->id.idiag_if, tbl); +#if defined(CONFIG_IPV6 ) || defined (CONFIG_IPV6_MODULE )
strange space after second 'defined' ;)
By the way, we can now use :
#if IS_ENABLED(CONFIG_IPV6)
David Miller
maintainerRe: [PATCH 2/2] udp_diag: Fix the !ipv6 case
From: Eric Dumazet <[email protected]>
Date: Sat, 10 Dec 2011 12:02:11 +0100
Quoted 19 lines · Pavel Emelyanov
Quoted 11 lines
Wrap the udp6 lookup into the proper ifdef-s.
Signed-off-by Pavel Emelyanov <[email protected]>---
net/ipv4/udp_diag.c +0
-0net/ipv4/udp_diag.c static int udp_dump_one(struct udp_table *tbl, struct sk_buff *in_skb, · line 44
Quoted 4 lines
net/ipv4/udp_diag.c +1
-0@@ -41,6 +41,7 @@ static int udp_dump_one(struct udp_table *tbl, struct sk_buff *in_skb, req->id.idiag_src[0 ], req->id.idiag_sport, req->id.idiag_dst[0 ], req->id.idiag_dport, req->id.idiag_if, tbl); +#if defined(CONFIG_IPV6 ) || defined (CONFIG_IPV6_MODULE )strange space after second 'defined' ;)
Quoted 3 lines
By the way, we can now use :
#if
IS_ENABLED(CONFIG_IPV6)
I applied this patch, changing it to use IS_ENABLED() along the way.
Thanks.
PATCH 1/1 net: use IS_ENABLED(CONFIG_IPV6)
Instead of testing defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
--- include/linux/errqueue.h | 4 +- include/linux/ipv6.h | 4 +- include/linux/lockd/lockd.h | 6 ++-- include/linux/sunrpc/clnt.h | 6 ++-- include/net/inet6_hashtables.h | 4 +- include/net/inet_sock.h | 6 ++-- include/net/ip.h | 6 ++-- include/net/net_namespace.h | 2 - include/net/netfilter/nf_tproxy_core.h | 2 - include/net/netns/mib.h | 2 - include/net/netns/xfrm.h | 2 - include/net/protocol.h | 8 ++--- include/net/sctp/sctp.h | 4 +- include/net/sctp/structs.h | 2 - include/net/tcp.h | 6 ++-- include/net/udp.h | 4 +- net/bridge/br_multicast.c | 32 +++++++++++------------ net/bridge/br_private.h | 2 - net/core/secure_seq.c | 4 +- net/dccp/dccp.h | 2 - net/dccp/minisocks.c | 2 - net/ipv4/inet_connection_sock.c | 2 - net/ipv4/inet_diag.c | 16 +++++------ net/ipv4/ip_gre.c | 8 ++--- net/ipv4/ip_sockglue.c | 6 ++-- net/ipv4/tcp_input.c | 2 - net/ipv4/tcp_minisocks.c | 2 - net/ipv4/tcp_timer.c | 2 - net/ipv4/tunnel4.c | 10 +++---- net/ipv4/xfrm4_tunnel.c | 6 ++-- net/key/af_key.c | 18 ++++++------ net/netfilter/xt_TEE.c | 9 ++---- net/netlabel/netlabel_addrlist.c | 8 ++--- net/netlabel/netlabel_addrlist.h | 2 - net/netlabel/netlabel_domainhash.c | 20 +++++++------- net/netlabel/netlabel_domainhash.h | 2 - net/netlabel/netlabel_kapi.c | 18 ++++++------ net/netlabel/netlabel_mgmt.c | 6 ++-- net/netlabel/netlabel_unlabeled.c | 26 +++++++++--------- net/sctp/input.c | 2 - net/sctp/protocol.c | 2 - net/sctp/socket.c | 4 +- net/sunrpc/addr.c | 8 ++--- net/sunrpc/svc.c | 8 ++--- net/sunrpc/svc_xprt.c | 8 ++--- net/sunrpc/svcauth_unix.c | 2 - net/xfrm/xfrm_policy.c | 6 ++-- net/xfrm/xfrm_user.c | 12 ++++---- 48 files changed, 161 insertions(+), 164 deletions(-)
include/linux/errqueue.h +2 -2
@@ -25,7 +25,7 @@ struct sock_extended_err {#ifdef __KERNEL__#include <net/ip.h> -#if defined(CONFIG_IPV6 ) || defined (CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )#include <linux/ipv6.h> #endif
@@ -34,7 +34,7 @@ struct sock_extended_err {struct sock_exterr_skb {union {struct inet_skb_parm h4; -#if defined(CONFIG_IPV6 ) || defined (CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )struct inet6_skb_parm h6;#endif } header;
include/linux/ipv6.h +2 -2
@@ -404,7 +404,7 @@ struct tcp6_sock {extern int inet6_sk_rebuild_header (struct sock *sk); -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )static inline struct ipv6_pinfo *inet6_sk (const struct sock *__sk) {return inet_sk (__sk)->pinet6;
@@ -515,7 +515,7 @@ static inline struct raw6_sock *raw6_sk(const struct sock *sk)#define inet6_rcv_saddr (__sk) NULL#define tcp_twsk_ipv6only (__sk) 0#define inet_v6_ipv6only (__sk) 0 -#endif /* defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) */ +#endif /* IS_ENABLED(CONFIG_IPV6) */ #define INET6_MATCH (__sk, __net, __hash, __saddr, __daddr, __ports, __dif)\ (((__sk)->sk_hash == (__hash)) && sock_net((__sk)) == (__net) && \
include/linux/lockd/lockd.h +3 -3
@@ -301,7 +301,7 @@ static inline int __nlm_privileged_request4(const struct sockaddr *sap)return ipv4_is_loopback (sin->sin_addr.s_addr); } -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )static inline int __nlm_privileged_request6 (const struct sockaddr *sap) {const struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)sap;
@@ -314,12 +314,12 @@ static inline int __nlm_privileged_request6(const struct sockaddr *sap) return ipv6_addr_type(&sin6->sin6_addr) & IPV6_ADDR_LOOPBACK; } -#else /* defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) */ +#else /* IS_ENABLED(CONFIG_IPV6) */ static inline int __nlm_privileged_request6 (const struct sockaddr *sap) {return 0 ; } -#endif /* defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) */ +#endif /* IS_ENABLED(CONFIG_IPV6) */ /* * Ensure incoming requests are from local privileged callers.
include/linux/sunrpc/clnt.h +3 -3
@@ -215,7 +215,7 @@ static inline bool __rpc_copy_addr4(struct sockaddr *dst,return true; } -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )static inline bool __rpc_cmp_addr6 (const struct sockaddr *sap1,const struct sockaddr *sap2) {
@@ -240,7 +240,7 @@ static inline bool __rpc_copy_addr6(struct sockaddr *dst, dsin6->sin6_addr = ssin6->sin6_addr; return true; } -#else /* !(CONFIG_IPV6 || CONFIG_IPV6_MODULE) */ +#else /* !(IS_ENABLED(CONFIG_IPV6) */ static inline bool __rpc_cmp_addr6 (const struct sockaddr *sap1,const struct sockaddr *sap2) {
@@ -252,7 +252,7 @@ static inline bool __rpc_copy_addr6(struct sockaddr *dst, {return false; } -#endif /* !(CONFIG_IPV6 || CONFIG_IPV6_MODULE) */ +#endif /* !(IS_ENABLED(CONFIG_IPV6) */ /** * rpc_cmp_addr - compare the address portion of two sockaddrs.
include/net/inet6_hashtables.h +2 -2
@@ -15,7 +15,7 @@#define _INET6_HASHTABLES_H -#if defined(CONFIG_IPV6 ) || defined (CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )#include <linux/in6.h> #include <linux/ipv6.h> #include <linux/types.h>
@@ -110,5 +110,5 @@ extern struct sock *inet6_lookup(struct net *net, struct inet_hashinfo *hashinfo const struct in6_addr *saddr, const __be16 sport, const struct in6_addr *daddr, const __be16 dport, const int dif); -#endif /* defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) */ +#endif /* IS_ENABLED(CONFIG_IPV6) */ #endif /* _INET6_HASHTABLES_H */
include/net/inet_sock.h +3 -3
@@ -71,7 +71,7 @@ struct ip_options_data {struct inet_request_sock {struct request_sock req; -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )u16 inet6_rsk_offset;#endif __be16 loc_port;
@@ -139,7 +139,7 @@ struct rtable;struct inet_sock {/* sk and pinet6 has to be the first two members of inet_sock */ struct sock sk; -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )struct ipv6_pinfo *pinet6;#endif /* Socket demultiplex comparisons on incoming packets. */
@@ -188,7 +188,7 @@ static inline void __inet_sk_copy_descendant(struct sock *sk_to,memcpy (inet_sk (sk_to) +1 ,inet_sk (sk_from) +1 , sk_from->sk_prot->obj_size - ancestor_size); } -#if !(defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE )) +#if !(IS_ENABLED (CONFIG_IPV6 ))static inline void inet_sk_copy_descendant (struct sock *sk_to,const struct sock *sk_from) {
include/net/ip.h +3 -3
@@ -353,14 +353,14 @@ static inline void ip_ipgre_mc_map(__be32 naddr, const unsigned char *broadcast,memcpy (buf, &naddr,sizeof (naddr)); } -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )#include <linux/ipv6.h> #endif static __inline__void inet_reset_saddr (struct sock *sk) {inet_sk (sk)->inet_rcv_saddr =inet_sk (sk)->inet_saddr =0 ; -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )if (sk->sk_family ==PF_INET6 ) {struct ipv6_pinfo *np =inet6_sk (sk);
@@ -379,7 +379,7 @@ static inline int sk_mc_loop(struct sock *sk)switch (sk->sk_family) {case AF_INET :return inet_sk (sk)->mc_loop; -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )case AF_INET6 :return inet6_sk (sk)->mc_loop;#endif
include/net/net_namespace.h +1 -1
@@ -77,7 +77,7 @@ struct net {struct netns_packet packet;struct netns_unix unx;struct netns_ipv4 ipv4; -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )struct netns_ipv6 ipv6;#endif #if defined(CONFIG_IP_DCCP ) || defined(CONFIG_IP_DCCP_MODULE )
include/net/netfilter/nf_tproxy_core.h +1 -1
@@ -131,7 +131,7 @@ nf_tproxy_get_sock_v4(struct net *net, const u8 protocol,return sk; } -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )static inline struct sock * nf_tproxy_get_sock_v6(struct net *net, const u8 protocol, const struct in6_addr *saddr, const struct in6_addr *daddr,
include/net/netns/mib.h +1 -1
@@ -12,7 +12,7 @@ struct netns_mib { DEFINE_SNMP_STAT(struct icmp_mib, icmp_statistics); DEFINE_SNMP_STAT_ATOMIC(struct icmpmsg_mib, icmpmsg_statistics); -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )struct proc_dir_entry *proc_net_devsnmp6; DEFINE_SNMP_STAT(struct udp_mib, udp_stats_in6); DEFINE_SNMP_STAT(struct udp_mib, udplite_stats_in6);
include/net/netns/xfrm.h +1 -1
@@ -56,7 +56,7 @@ struct netns_xfrm {#endif struct dst_ops xfrm4_dst_ops; -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )struct dst_ops xfrm6_dst_ops;#endif };
include/net/protocol.h +4 -4
@@ -25,7 +25,7 @@#define _PROTOCOL_H#include <linux/in6.h> -#if defined(CONFIG_IPV6 ) || defined (CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )#include <linux/ipv6.h> #endif
@@ -46,7 +46,7 @@ struct net_protocol { netns_ok:1 ; }; -#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) +#if IS_ENABLED(CONFIG_IPV6) struct inet6_protocol { int (*handler)(struct sk_buff *skb);
@@ -91,7 +91,7 @@ struct inet_protosw {extern const struct net_protocol __rcu *inet_protos[MAX_INET_PROTOS ]; -#if defined(CONFIG_IPV6 ) || defined (CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )extern const struct inet6_protocol __rcu *inet6_protos[MAX_INET_PROTOS ];#endif
@@ -100,7 +100,7 @@ extern int inet_del_protocol(const struct net_protocol *prot, unsigned char num)extern void inet_register_protosw (struct inet_protosw *p);extern void inet_unregister_protosw (struct inet_protosw *p); -#if defined(CONFIG_IPV6 ) || defined (CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )extern int inet6_add_protocol (const struct inet6_protocol *prot,unsigned char num);extern int inet6_del_protocol (const struct inet6_protocol *prot,unsigned char num);extern int inet6_register_protosw (struct inet_protosw *p);
include/net/sctp/sctp.h +2 -2
@@ -71,7 +71,7 @@#include <linux/jiffies.h> #include <linux/idr.h> -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )#include <net/ipv6.h> #include <net/ip6_route.h> #endif
@@ -383,7 +383,7 @@ static inline void sctp_sysctl_unregister(void) { return; }/* Size of Supported Address Parameter for 'x' address types. */ #define SCTP_SAT_LEN (x) (sizeof(struct sctp_paramhdr) + (x) * sizeof(__u16)) -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )void sctp_v6_pf_init (void );void sctp_v6_pf_exit (void );
include/net/sctp/structs.h +1 -1
@@ -365,7 +365,7 @@ static inline struct sock *sctp_opt2sk(const struct sctp_sock *sp)return (struct sock *)sp; } -#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) +#if IS_ENABLED(CONFIG_IPV6) struct sctp6_sock { struct sctp_sock sctp; struct ipv6_pinfo inet6;
include/net/tcp.h +3 -3
@@ -628,7 +628,7 @@ extern u32 __tcp_select_window(struct sock *sk);struct tcp_skb_cb {union {struct inet_skb_parm h4; -#if defined(CONFIG_IPV6 ) || defined (CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )struct inet6_skb_parm h6;#endif } header;/* For incoming frames */
@@ -1152,7 +1152,7 @@ struct tcp6_md5sig_key {/* - sock block */ struct tcp_md5sig_info {struct tcp4_md5sig_key *keys4; -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )struct tcp6_md5sig_key *keys6;u32 entries6;u32 alloced6;
@@ -1179,7 +1179,7 @@ struct tcp6_pseudohdr {union tcp_md5sum_block {struct tcp4_pseudohdr ip4; -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )struct tcp6_pseudohdr ip6;#endif };
include/net/udp.h +2 -2
@@ -41,7 +41,7 @@struct udp_skb_cb {union {struct inet_skb_parm h4; -#if defined(CONFIG_IPV6 ) || defined (CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )struct inet6_skb_parm h6;#endif } header;
@@ -223,7 +223,7 @@ extern struct sock *__udp6_lib_lookup(struct net *net, const struct in6_addr *sa else SNMP_INC_STATS_USER((net)->mib.udp_stats_in6, field); \ } while(0) -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )#define UDPX_INC_STATS_BH (sk, field) \ do { \ if ((sk)->sk_family == AF_INET) \
net/bridge/br_multicast.c +16 -16
@@ -24,7 +24,7 @@#include <linux/slab.h> #include <linux/timer.h> #include <net/ip.h> -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )#include <net/ipv6.h> #include <net/mld.h> #include <net/addrconf.h>
@@ -36,7 +36,7 @@#define mlock_dereference (X , br) \ rcu_dereference_protected(X, lockdep_is_held(&br->multicast_lock)) -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )static inline int ipv6_is_transient_multicast (const struct in6_addr *addr) {if (ipv6_addr_is_multicast (addr) &&IPV6_ADDR_MC_FLAG_TRANSIENT (addr))
@@ -52,7 +52,7 @@ static inline int br_ip_equal(const struct br_ip *a, const struct br_ip *b)switch (a->proto) {case htons (ETH_P_IP ):return a->u.ip4 == b->u.ip4; -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )case htons (ETH_P_IPV6 ):return ipv6_addr_equal (&a->u.ip6, &b->u.ip6);#endif
@@ -65,7 +65,7 @@ static inline int __br_ip4_hash(struct net_bridge_mdb_htable *mdb, __be32 ip)return jhash_1word (mdb->secret, (__force u32 )ip) & (mdb->max -1 ); } -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )static inline int __br_ip6_hash (struct net_bridge_mdb_htable *mdb,const struct in6_addr *ip) {
@@ -79,7 +79,7 @@ static inline int br_ip_hash(struct net_bridge_mdb_htable *mdb,switch (ip->proto) {case htons (ETH_P_IP ):return __br_ip4_hash (mdb, ip->u.ip4); -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )case htons (ETH_P_IPV6 ):return __br_ip6_hash (mdb, &ip->u.ip6);#endif
@@ -121,7 +121,7 @@ static struct net_bridge_mdb_entry *br_mdb_ip4_get(return br_mdb_ip_get (mdb, &br_dst); } -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )static struct net_bridge_mdb_entry *br_mdb_ip6_get (struct net_bridge_mdb_htable *mdb,const struct in6_addr *dst) {
@@ -152,7 +152,7 @@ struct net_bridge_mdb_entry *br_mdb_get(struct net_bridge *br,case htons (ETH_P_IP ): ip.u.ip4 =ip_hdr (skb)->daddr;break ; -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )case htons (ETH_P_IPV6 ): ip.u.ip6 =ipv6_hdr (skb)->daddr;break ;
@@ -411,7 +411,7 @@ out:return skb; } -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )static struct sk_buff *br_ip6_multicast_alloc_query (struct net_bridge *br,const struct in6_addr *group) {
@@ -496,7 +496,7 @@ static struct sk_buff *br_multicast_alloc_query(struct net_bridge *br,switch (addr->proto) {case htons (ETH_P_IP ):return br_ip4_multicast_alloc_query (br, addr->u.ip4); -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )case htons (ETH_P_IPV6 ):return br_ip6_multicast_alloc_query (br, &addr->u.ip6);#endif
@@ -773,7 +773,7 @@ static int br_ip4_multicast_add_group(struct net_bridge *br,return br_multicast_add_group (br, port, &br_group); } -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )static int br_ip6_multicast_add_group (struct net_bridge *br,struct net_bridge_port *port,const struct in6_addr *group)
@@ -845,7 +845,7 @@ static void br_multicast_send_query(struct net_bridge *br, br_group.proto =htons (ETH_P_IP );__br_multicast_send_query (br, port, &br_group); -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 ) br_group.proto =htons (ETH_P_IPV6 );__br_multicast_send_query (br, port, &br_group);#endif
@@ -989,7 +989,7 @@ static int br_ip4_multicast_igmp3_report(struct net_bridge *br,return err; } -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )static int br_ip6_multicast_mld2_report (struct net_bridge *br,struct net_bridge_port *port,struct sk_buff *skb)
@@ -1185,7 +1185,7 @@ out:return err; } -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )static int br_ip6_multicast_query (struct net_bridge *br,struct net_bridge_port *port,struct sk_buff *skb)
@@ -1334,7 +1334,7 @@ static void br_ip4_multicast_leave_group(struct net_bridge *br,br_multicast_leave_group (br, port, &br_group); } -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )static void br_ip6_multicast_leave_group (struct net_bridge *br,struct net_bridge_port *port,const struct in6_addr *group)
@@ -1449,7 +1449,7 @@ err_out:return err; } -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )static int br_multicast_ipv6_rcv (struct net_bridge *br,struct net_bridge_port *port,struct sk_buff *skb)
@@ -1596,7 +1596,7 @@ int br_multicast_rcv(struct net_bridge *br, struct net_bridge_port *port,switch (skb->protocol) {case htons (ETH_P_IP ):return br_multicast_ipv4_rcv (br, port, skb); -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )case htons (ETH_P_IPV6 ):return br_multicast_ipv6_rcv (br, port, skb);#endif
net/bridge/br_private.h +1 -1
@@ -56,7 +56,7 @@ struct br_ip {union {__be32 ip4; -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )struct in6_addr ip6;#endif } u;
net/core/secure_seq.c +2 -2
@@ -36,7 +36,7 @@ static u32 seq_scale(u32 seq) }#endif -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )__u32 secure_tcpv6_sequence_number (const __be32 *saddr,const __be32 *daddr,__be16 sport,__be16 dport) {
@@ -156,7 +156,7 @@ u64 secure_dccp_sequence_number(__be32 saddr, __be32 daddr, }EXPORT_SYMBOL (secure_dccp_sequence_number); -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )u64 secure_dccpv6_sequence_number (__be32 *saddr,__be32 *daddr,__be16 sport,__be16 dport) {
net/dccp/dccp.h +1 -1
@@ -357,7 +357,7 @@ static inline int dccp_bad_service_code(const struct sock *sk,struct dccp_skb_cb {union {struct inet_skb_parm h4; -#if defined(CONFIG_IPV6 ) || defined (CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )struct inet6_skb_parm h6;#endif } header;
net/dccp/minisocks.c +1 -1
@@ -53,7 +53,7 @@ void dccp_time_wait(struct sock *sk, int state, int timeo)if (tw !=NULL ) {const struct inet_connection_sock *icsk =inet_csk (sk);const int rto = (icsk->icsk_rto <<2 ) - (icsk->icsk_rto >>1 ); -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )if (tw->tw_family ==PF_INET6 ) {const struct ipv6_pinfo *np =inet6_sk (sk);struct inet6_timewait_sock *tw6;
net/ipv4/inet_connection_sock.c +1 -1
@@ -418,7 +418,7 @@ static inline u32 inet_synq_hash(const __be32 raddr, const __be16 rport,return jhash_2words ((__force u32 )raddr, (__force u32 )rport, rnd) & (synq_hsize -1 ); } -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )#define AF_INET_FAMILY (fam) ((fam) == AF_INET)#else #define AF_INET_FAMILY (fam) 1
net/ipv4/inet_diag.c +8 -8
@@ -116,7 +116,7 @@ int inet_sk_diag_fill(struct sock *sk, struct inet_connection_sock *icsk,if (ext & (1 << (INET_DIAG_TOS -1 )))RTA_PUT_U8 (skb,INET_DIAG_TOS , inet->tos); -#if defined(CONFIG_IPV6 ) || defined (CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )if (r->idiag_family ==AF_INET6 ) {const struct ipv6_pinfo *np =inet6_sk (sk);
@@ -234,7 +234,7 @@ static int inet_twsk_diag_fill(struct inet_timewait_sock *tw, r->idiag_wqueue =0 ; r->idiag_uid =0 ; r->idiag_inode =0 ; -#if defined(CONFIG_IPV6 ) || defined (CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )if (tw->tw_family ==AF_INET6 ) {const struct inet6_timewait_sock *tw6 =inet6_twsk ((struct sock *)tw);
@@ -286,7 +286,7 @@ int inet_diag_dump_one_icsk(struct inet_hashinfo *hashinfo, struct sk_buff *in_s req->id.idiag_dport, req->id.idiag_src[0 ], req->id.idiag_sport, req->id.idiag_if); } -#if defined(CONFIG_IPV6 ) || defined (CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 ) else if (req->sdiag_family == AF_INET6) { sk = inet6_lookup(&init_net, hashinfo, (struct in6_addr *)req->id.idiag_dst,
@@ -473,7 +473,7 @@ int inet_diag_bc_sk(const struct nlattr *bc, struct sock *sk)return 1 ; entry.family = sk->sk_family; -#if defined(CONFIG_IPV6 ) || defined (CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )if (entry.family ==AF_INET6 ) {struct ipv6_pinfo *np =inet6_sk (sk);
@@ -571,7 +571,7 @@ static int inet_twsk_diag_dump(struct inet_timewait_sock *tw,struct inet_diag_entry entry; entry.family = tw->tw_family; -#if defined(CONFIG_IPV6 ) || defined (CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )if (tw->tw_family ==AF_INET6 ) {struct inet6_timewait_sock *tw6 =inet6_twsk ((struct sock *)tw);
@@ -633,7 +633,7 @@ static int inet_diag_fill_req(struct sk_buff *skb, struct sock *sk, r->idiag_wqueue =0 ; r->idiag_uid =sock_i_uid (sk); r->idiag_inode =0 ; -#if defined(CONFIG_IPV6 ) || defined (CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )if (r->idiag_family ==AF_INET6 ) { *(struct in6_addr *)r->id.idiag_src =inet6_rsk (req)->loc_addr; *(struct in6_addr *)r->id.idiag_dst =inet6_rsk (req)->rmt_addr;
@@ -695,13 +695,13 @@ static int inet_diag_dump_reqs(struct sk_buff *skb, struct sock *sk,if (bc) { entry.saddr = -#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) +#if IS_ENABLED(CONFIG_IPV6) (entry.family ==AF_INET6 ) ?inet6_rsk (req)->loc_addr.s6_addr32 : #endif &ireq->loc_addr; entry.daddr = -#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) +#if IS_ENABLED(CONFIG_IPV6) (entry.family == AF_INET6) ? inet6_rsk(req)->rmt_addr.s6_addr32 : #endif
net/ipv4/ip_gre.c +4 -4
@@ -46,7 +46,7 @@#include <net/rtnetlink.h> #include <net/gre.h> -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )#include <net/ipv6.h> #include <net/ip6_fib.h> #include <net/ip6_route.h>
@@ -729,7 +729,7 @@ static netdev_tx_t ipgre_tunnel_xmit(struct sk_buff *skb, struct net_device *devif ((dst = rt->rt_gateway) ==0 ) goto tx_error_icmp; } -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 ) else if (skb->protocol == htons(ETH_P_IPV6)) {struct neighbour *neigh =dst_get_neighbour_noref (skb_dst (skb));const struct in6_addr *addr6;
@@ -799,7 +799,7 @@ static netdev_tx_t ipgre_tunnel_xmit(struct sk_buff *skb, struct net_device *dev goto tx_error; } } -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 ) else if (skb->protocol == htons(ETH_P_IPV6)) {struct rt6_info *rt6 = (struct rt6_info *)skb_dst (skb);
@@ -875,7 +875,7 @@ static netdev_tx_t ipgre_tunnel_xmit(struct sk_buff *skb, struct net_device *devif ((iph->ttl = tiph->ttl) ==0 ) {if (skb->protocol ==htons (ETH_P_IP )) iph->ttl = old_iph->ttl; -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 ) else if (skb->protocol == htons(ETH_P_IPV6)) iph->ttl = ((const struct ipv6hdr *)old_iph)->hop_limit;#endif
net/ipv4/ip_sockglue.c +3 -3
@@ -37,7 +37,7 @@#include <net/route.h> #include <net/xfrm.h> #include <net/compat.h> -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )#include <net/transp_v6.h> #endif
@@ -508,7 +508,7 @@ static int do_ip_setsockopt(struct sock *sk, int level, sock_owned_by_user(sk));if (inet->is_icsk) {struct inet_connection_sock *icsk =inet_csk (sk); -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 ) if (sk->sk_family == PF_INET || (!((1 << sk->sk_state) & (TCPF_LISTEN | TCPF_CLOSE)) &&
@@ -519,7 +519,7 @@ static int do_ip_setsockopt(struct sock *sk, int level,if (opt) icsk->icsk_ext_hdr_len += opt->opt.optlen; icsk->icsk_sync_mss (sk, icsk->icsk_pmtu_cookie); -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 ) }#endif }
net/ipv4/tcp_input.c +1 -1
@@ -2663,7 +2663,7 @@ static void DBGUNDO(struct sock *sk, const char *msg) tp->snd_ssthresh, tp->prior_ssthresh, tp->packets_out); } -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 ) else if (sk->sk_family == AF_INET6) {struct ipv6_pinfo *np =inet6_sk (sk); printk(KERN_DEBUG "Undo %s %pI6/%u c%u l%u ss%u/%u p%u\n",
net/ipv4/tcp_minisocks.c +1 -1
@@ -336,7 +336,7 @@ void tcp_time_wait(struct sock *sk, int state, int timeo) tcptw->tw_ts_recent = tp->rx_opt.ts_recent; tcptw->tw_ts_recent_stamp = tp->rx_opt.ts_recent_stamp; -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )if (tw->tw_family ==PF_INET6 ) {struct ipv6_pinfo *np =inet6_sk (sk);struct inet6_timewait_sock *tw6;
net/ipv4/tcp_timer.c +1 -1
@@ -340,7 +340,7 @@ void tcp_retransmit_timer(struct sock *sk) &inet->inet_daddr,ntohs (inet->inet_dport), inet->inet_num, tp->snd_una, tp->snd_nxt); } -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 ) else if (sk->sk_family == AF_INET6) {struct ipv6_pinfo *np =inet6_sk (sk); LIMIT_NETDEBUG(KERN_DEBUG "TCP: Peer %pI6:%u/%u unexpectedly shrunk window %u:%u (repaired)\n",
net/ipv4/tunnel4.c +5 -5
@@ -105,7 +105,7 @@ drop:return 0 ; } -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )static int tunnel64_rcv (struct sk_buff *skb) {struct xfrm_tunnel *handler;
@@ -134,7 +134,7 @@ static void tunnel4_err(struct sk_buff *skb, u32 info)break ; } -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )static void tunnel64_err (struct sk_buff *skb,u32 info) {struct xfrm_tunnel *handler;
@@ -152,7 +152,7 @@ static const struct net_protocol tunnel4_protocol = { .netns_ok = 1, }; -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )static const struct net_protocol tunnel64_protocol = { .handler = tunnel64_rcv, .err_handler = tunnel64_err,
@@ -167,7 +167,7 @@ static int __init tunnel4_init(void)printk (KERN_ERR "tunnel4 init: can't add protocol\n" );return -EAGAIN ; } -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )if (inet_add_protocol (&tunnel64_protocol,IPPROTO_IPV6 )) {printk (KERN_ERR "tunnel64 init: can't add protocol\n" );inet_del_protocol (&tunnel4_protocol,IPPROTO_IPIP );
@@ -179,7 +179,7 @@ static int __init tunnel4_init(void) static void __exit tunnel4_fini(void) { -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )if (inet_del_protocol (&tunnel64_protocol,IPPROTO_IPV6 ))printk (KERN_ERR "tunnel64 close: can't remove protocol\n" );#endif
net/ipv4/xfrm4_tunnel.c +3 -3
@@ -64,7 +64,7 @@ static struct xfrm_tunnel xfrm_tunnel_handler __read_mostly = { .priority = 2, }; -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )static struct xfrm_tunnel xfrm64_tunnel_handler__read_mostly = { .handler = xfrm_tunnel_rcv, .err_handler = xfrm_tunnel_err,
@@ -84,7 +84,7 @@ static int __init ipip_init(void)xfrm_unregister_type (&ipip_type,AF_INET );return -EAGAIN ; } -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )if (xfrm4_tunnel_register (&xfrm64_tunnel_handler,AF_INET6 )) {printk (KERN_INFO "ipip init: can't add xfrm handler for AF_INET6\n" );xfrm4_tunnel_deregister (&xfrm_tunnel_handler,AF_INET );
@@ -97,7 +97,7 @@ static int __init ipip_init(void) static void __exit ipip_fini(void) { -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )if (xfrm4_tunnel_deregister (&xfrm64_tunnel_handler,AF_INET6 ))printk (KERN_INFO "ipip close: can't remove xfrm handler for AF_INET6\n" );#endif
net/key/af_key.c +9 -9
@@ -375,7 +375,7 @@ static int verify_address_len(const void *p)const struct sadb_address *sp = p;const struct sockaddr *addr = (const struct sockaddr *)(sp +1 );const struct sockaddr_in *sin; -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )const struct sockaddr_in6 *sin6;#endif int len;
@@ -387,7 +387,7 @@ static int verify_address_len(const void *p) sp->sadb_address_prefixlen > 32)return -EINVAL ;break ; -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )case AF_INET6 : len =DIV_ROUND_UP (sizeof (*sp) +sizeof (*sin6),sizeof (uint64_t )); if (sp->sadb_address_len != len ||
@@ -469,7 +469,7 @@ static int present_and_same_family(const struct sadb_address *src,if (s_addr->sa_family != d_addr->sa_family)return 0 ; if (s_addr->sa_family != AF_INET -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED(CONFIG_IPV6) && s_addr->sa_family !=AF_INET6 #endif )
@@ -579,7 +579,7 @@ static inline int pfkey_sockaddr_len(sa_family_t family)switch (family) {case AF_INET :return sizeof (struct sockaddr_in ); -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )case AF_INET6 :return sizeof (struct sockaddr_in6 );#endif
@@ -595,7 +595,7 @@ int pfkey_sockaddr_extract(const struct sockaddr *sa, xfrm_address_t *xaddr) xaddr->a4 = ((struct sockaddr_in *)sa)->sin_addr.s_addr;return AF_INET ; -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )case AF_INET6 : memcpy(xaddr->a6, &((struct sockaddr_in6 *)sa)->sin6_addr,
@@ -639,7 +639,7 @@ static struct xfrm_state *pfkey_xfrm_state_lookup(struct net *net, const structcase AF_INET : xaddr = (xfrm_address_t *)&((const struct sockaddr_in *)(addr +1 ))->sin_addr;break ; -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )case AF_INET6 : xaddr = (xfrm_address_t *)&((const struct sockaddr_in6 *)(addr +1 ))->sin6_addr;break ;
@@ -705,7 +705,7 @@ static unsigned int pfkey_sockaddr_fill(const xfrm_address_t *xaddr, __be16 portmemset (sin->sin_zero,0 ,sizeof (sin->sin_zero));return 32 ; } -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )case AF_INET6 : {struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)sa;
@@ -1311,7 +1311,7 @@ static int pfkey_getspi(struct sock *sk, struct sk_buff *skb, const struct sadb_ xdaddr = (xfrm_address_t *)&((struct sockaddr_in *)(daddr +1 ))->sin_addr.s_addr; xsaddr = (xfrm_address_t *)&((struct sockaddr_in *)(saddr +1 ))->sin_addr.s_addr;break ; -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )case AF_INET6 : xdaddr = (xfrm_address_t *)&((struct sockaddr_in6 *)(daddr +1 ))->sin6_addr; xsaddr = (xfrm_address_t *)&((struct sockaddr_in6 *)(saddr +1 ))->sin6_addr;
@@ -3146,7 +3146,7 @@ static struct xfrm_policy *pfkey_compile_policy(struct sock *sk, int opt,return NULL ; }break ; -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )case AF_INET6 :if (opt !=IPV6_IPSEC_POLICY ) { *dir = -EOPNOTSUPP ;
net/netfilter/xt_TEE.c +3 -6
@@ -29,9 +29,6 @@# define WITH_CONNTRACK 1# include <net/netfilter/nf_conntrack.h> #endif -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) -# define WITH_IPV6 1 -#endif struct xt_tee_priv {struct notifier_block notifier;
@@ -136,7 +133,7 @@ tee_tg4(struct sk_buff *skb, const struct xt_action_param *par)return XT_CONTINUE ; } -#ifdef WITH_IPV6 +#if IS_ENABLED (CONFIG_IPV6 )static bool tee_tg_route6 (struct sk_buff *skb,const struct xt_tee_tginfo *info) {
@@ -196,7 +193,7 @@ tee_tg6(struct sk_buff *skb, const struct xt_action_param *par) }return XT_CONTINUE ; } -#endif /* WITH_IPV6 */ +#endif static int tee_netdev_event (struct notifier_block *this,unsigned long event,void *ptr)
@@ -276,7 +273,7 @@ static struct xt_target tee_tg_reg[] __read_mostly = { .destroy = tee_tg_destroy, .me = THIS_MODULE, }, -#ifdef WITH_IPV6 +#if IS_ENABLED (CONFIG_IPV6 ) { .name = "TEE", .revision = 1,
net/netlabel/netlabel_addrlist.c +4 -4
@@ -96,7 +96,7 @@ struct netlbl_af4list *netlbl_af4list_search_exact(__be32 addr, } -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )/** * netlbl_af6list_search - Search for a matching IPv6 address entry * @addr: IPv6 address
@@ -185,7 +185,7 @@ int netlbl_af4list_add(struct netlbl_af4list *entry, struct list_head *head)return 0 ; } -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )/** * netlbl_af6list_add - Add a new IPv6 address entry to a list * @entry: address entry
@@ -263,7 +263,7 @@ struct netlbl_af4list *netlbl_af4list_remove(__be32 addr, __be32 mask,return entry; } -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )/** * netlbl_af6list_remove_entry - Remove an IPv6 address entry * @entry: address entry
@@ -342,7 +342,7 @@ void netlbl_af4list_audit_addr(struct audit_buffer *audit_buf, } } -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )/** * netlbl_af6list_audit_addr - Audit an IPv6 address * @audit_buf: audit buffer
net/netlabel/netlabel_addrlist.h +1 -1
@@ -133,7 +133,7 @@ static inline void netlbl_af4list_audit_addr(struct audit_buffer *audit_buf, }#endif -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )#define __af6list_entry (ptr) container_of(ptr, struct netlbl_af6list, list)
net/netlabel/netlabel_domainhash.c +10 -10
@@ -78,7 +78,7 @@ static void netlbl_domhsh_free_entry(struct rcu_head *entry)struct netlbl_dom_map *ptr;struct netlbl_af4list *iter4;struct netlbl_af4list *tmp4; -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )struct netlbl_af6list *iter6;struct netlbl_af6list *tmp6;#endif /* IPv6 */
@@ -90,7 +90,7 @@ static void netlbl_domhsh_free_entry(struct rcu_head *entry)netlbl_af4list_remove_entry (iter4);kfree (netlbl_domhsh_addr4_entry (iter4)); } -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )netlbl_af6list_foreach_safe (iter6, tmp6, &ptr->type_def.addrsel->list6) {netlbl_af6list_remove_entry (iter6);
@@ -217,7 +217,7 @@ static void netlbl_domhsh_audit_add(struct netlbl_dom_map *entry, cipsov4 = map4->type_def.cipsov4;netlbl_af4list_audit_addr (audit_buf,0 ,NULL , addr4->addr, addr4->mask); -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 ) } else if (addr6 != NULL) {struct netlbl_domaddr6_map *map6; map6 =netlbl_domhsh_addr6_entry (addr6);
@@ -306,7 +306,7 @@ int netlbl_domhsh_add(struct netlbl_dom_map *entry,struct netlbl_dom_map *entry_old;struct netlbl_af4list *iter4;struct netlbl_af4list *tmp4; -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )struct netlbl_af6list *iter6;struct netlbl_af6list *tmp6;#endif /* IPv6 */
@@ -338,7 +338,7 @@ int netlbl_domhsh_add(struct netlbl_dom_map *entry, &entry->type_def.addrsel->list4)netlbl_domhsh_audit_add (entry, iter4,NULL , ret_val, audit_info); -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )netlbl_af6list_foreach_rcu (iter6, &entry->type_def.addrsel->list6) netlbl_domhsh_audit_add(entry, NULL, iter6,
@@ -365,7 +365,7 @@ int netlbl_domhsh_add(struct netlbl_dom_map *entry, ret_val = -EEXIST ; goto add_return; } -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )netlbl_af6list_foreach_rcu (iter6, &entry->type_def.addrsel->list6) if (netlbl_af6list_search_exact(&iter6->addr,
@@ -386,7 +386,7 @@ int netlbl_domhsh_add(struct netlbl_dom_map *entry,if (ret_val !=0 ) goto add_return; } -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )netlbl_af6list_foreach_safe (iter6, tmp6, &entry->type_def.addrsel->list6) {netlbl_af6list_remove_entry (iter6);
@@ -510,7 +510,7 @@ int netlbl_domhsh_remove_af4(const char *domain,struct netlbl_dom_map *entry_map;struct netlbl_af4list *entry_addr;struct netlbl_af4list *iter4; -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )struct netlbl_af6list *iter6;#endif /* IPv6 */ struct netlbl_domaddr4_map *entry;
@@ -533,7 +533,7 @@ int netlbl_domhsh_remove_af4(const char *domain, goto remove_af4_failure; netlbl_af4list_foreach_rcu(iter4, &entry_map->type_def.addrsel->list4) goto remove_af4_single_addr; -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 ) netlbl_af6list_foreach_rcu(iter6, &entry_map->type_def.addrsel->list6) goto remove_af4_single_addr;#endif /* IPv6 */
@@ -644,7 +644,7 @@ struct netlbl_domaddr4_map *netlbl_domhsh_getentry_af4(const char *domain,return netlbl_domhsh_addr4_entry (addr_iter); } -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )/** * netlbl_domhsh_getentry_af6 - Get an entry from the domain hash table * @domain: the domain name to search for
net/netlabel/netlabel_domainhash.h +1 -1
@@ -104,7 +104,7 @@ int netlbl_domhsh_walk(u32 *skip_bkt,int (*callback) (struct netlbl_dom_map *entry,void *arg), void *cb_arg); -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )struct netlbl_domaddr6_map *netlbl_domhsh_getentry_af6 (const char *domain,const struct in6_addr *addr);#endif /* IPv6 */
net/netlabel/netlabel_kapi.c +9 -9
@@ -147,7 +147,7 @@ int netlbl_cfg_unlbl_map_add(const char *domain, goto cfg_unlbl_map_add_failure;break ; } -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )case AF_INET6 : {const struct in6_addr *addr6 = addr;const struct in6_addr *mask6 = mask;
@@ -227,7 +227,7 @@ int netlbl_cfg_unlbl_static_add(struct net *net,case AF_INET : addr_len =sizeof (struct in_addr );break ; -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )case AF_INET6 : addr_len =sizeof (struct in6_addr );break ;
@@ -270,7 +270,7 @@ int netlbl_cfg_unlbl_static_del(struct net *net,case AF_INET : addr_len =sizeof (struct in_addr );break ; -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )case AF_INET6 : addr_len =sizeof (struct in6_addr );break ;
@@ -673,7 +673,7 @@ int netlbl_sock_setattr(struct sock *sk, ret_val = -ENOENT ; }break ; -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )case AF_INET6 :/* since we don't support any IPv6 labeling protocols right * now we can optimize everything away until we do */
@@ -724,7 +724,7 @@ int netlbl_sock_getattr(struct sock *sk,case AF_INET : ret_val =cipso_v4_sock_getattr (sk, secattr);break ; -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )case AF_INET6 : ret_val = -ENOMSG ;break ;
@@ -782,7 +782,7 @@ int netlbl_conn_setattr(struct sock *sk, ret_val = -ENOENT ; }break ; -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )case AF_INET6 :/* since we don't support any IPv6 labeling protocols right * now we can optimize everything away until we do */
@@ -853,7 +853,7 @@ int netlbl_req_setattr(struct request_sock *req, ret_val = -ENOENT ; }break ; -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )case AF_INET6 :/* since we don't support any IPv6 labeling protocols right * now we can optimize everything away until we do */
@@ -926,7 +926,7 @@ int netlbl_skbuff_setattr(struct sk_buff *skb, ret_val = -ENOENT ; }break ; -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )case AF_INET6 :/* since we don't support any IPv6 labeling protocols right * now we can optimize everything away until we do */
@@ -965,7 +965,7 @@ int netlbl_skbuff_getattr(const struct sk_buff *skb, cipso_v4_skbuff_getattr(skb, secattr) == 0)return 0 ;break ; -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )case AF_INET6 :break ;#endif /* IPv6 */
net/netlabel/netlabel_mgmt.c +3 -3
@@ -184,7 +184,7 @@ static int netlbl_mgmt_add_common(struct genl_info *info, entry->type =NETLBL_NLTYPE_ADDRSELECT ; entry->type_def.addrsel = addrmap; -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 ) } else if (info->attrs[NLBL_MGMT_A_IPV6ADDR]) {struct in6_addr *addr;struct in6_addr *mask;
@@ -270,7 +270,7 @@ static int netlbl_mgmt_listentry(struct sk_buff *skb,struct nlattr *nla_a;struct nlattr *nla_b;struct netlbl_af4list *iter4; -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )struct netlbl_af6list *iter6;#endif
@@ -324,7 +324,7 @@ static int netlbl_mgmt_listentry(struct sk_buff *skb,nla_nest_end (skb, nla_b); } -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )netlbl_af6list_foreach_rcu (iter6, &entry->type_def.addrsel->list6) {struct netlbl_domaddr6_map *map6;
net/netlabel/netlabel_unlabeled.c +13 -13
@@ -170,7 +170,7 @@ static void netlbl_unlhsh_free_iface(struct rcu_head *entry)struct netlbl_unlhsh_iface *iface;struct netlbl_af4list *iter4;struct netlbl_af4list *tmp4; -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )struct netlbl_af6list *iter6;struct netlbl_af6list *tmp6;#endif /* IPv6 */
@@ -184,7 +184,7 @@ static void netlbl_unlhsh_free_iface(struct rcu_head *entry)netlbl_af4list_remove_entry (iter4);kfree (netlbl_unlhsh_addr4_entry (iter4)); } -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 ) netlbl_af6list_foreach_safe(iter6, tmp6, &iface->addr6_list) {netlbl_af6list_remove_entry (iter6);kfree (netlbl_unlhsh_addr6_entry (iter6));
@@ -274,7 +274,7 @@ static int netlbl_unlhsh_add_addr4(struct netlbl_unlhsh_iface *iface,return ret_val; } -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )/** * netlbl_unlhsh_add_addr6 - Add a new IPv6 address entry to the hash table * @iface: the associated interface entry
@@ -436,7 +436,7 @@ int netlbl_unlhsh_add(struct net *net, mask4->s_addr);break ; } -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )case sizeof (struct in6_addr ): {const struct in6_addr *addr6 = addr;const struct in6_addr *mask6 = mask;
@@ -531,7 +531,7 @@ static int netlbl_unlhsh_remove_addr4(struct net *net,return 0 ; } -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )/** * netlbl_unlhsh_remove_addr6 - Remove an IPv6 address entry * @net: network namespace
@@ -606,14 +606,14 @@ static int netlbl_unlhsh_remove_addr6(struct net *net,static void netlbl_unlhsh_condremove_iface (struct netlbl_unlhsh_iface *iface) {struct netlbl_af4list *iter4; -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )struct netlbl_af6list *iter6;#endif /* IPv6 */ spin_lock (&netlbl_unlhsh_lock); netlbl_af4list_foreach_rcu(iter4, &iface->addr4_list) goto unlhsh_condremove_failure; -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 ) netlbl_af6list_foreach_rcu(iter6, &iface->addr6_list) goto unlhsh_condremove_failure;#endif /* IPv6 */
@@ -680,7 +680,7 @@ int netlbl_unlhsh_remove(struct net *net, iface, addr, mask, audit_info);break ; -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )case sizeof (struct in6_addr ): ret_val = netlbl_unlhsh_remove_addr6(net, iface, addr, mask,
@@ -1196,7 +1196,7 @@ static int netlbl_unlabel_staticlist(struct sk_buff *skb,struct netlbl_unlhsh_iface *iface;struct list_head *iter_list;struct netlbl_af4list *addr4; -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )struct netlbl_af6list *addr6;#endif
@@ -1228,7 +1228,7 @@ static int netlbl_unlabel_staticlist(struct sk_buff *skb, goto unlabel_staticlist_return; } } -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )netlbl_af6list_foreach_rcu (addr6, &iface->addr6_list) {if (iter_addr6++ < skip_addr6)
@@ -1277,7 +1277,7 @@ static int netlbl_unlabel_staticlistdef(struct sk_buff *skb,u32 skip_addr6 = cb->args[1 ];u32 iter_addr4 =0 ;struct netlbl_af4list *addr4; -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )u32 iter_addr6 =0 ;struct netlbl_af6list *addr6;#endif
@@ -1303,7 +1303,7 @@ static int netlbl_unlabel_staticlistdef(struct sk_buff *skb, goto unlabel_staticlistdef_return; } } -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 ) netlbl_af6list_foreach_rcu(addr6, &iface->addr6_list) {if (iter_addr6++ < skip_addr6)continue ;
@@ -1494,7 +1494,7 @@ int netlbl_unlabel_getattr(const struct sk_buff *skb, secattr->attr.secid =netlbl_unlhsh_addr4_entry (addr4)->secid;break ; } -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )case PF_INET6 : {struct ipv6hdr *hdr6;struct netlbl_af6list *addr6;
net/sctp/input.c +1 -1
@@ -105,7 +105,7 @@ static inline int sctp_rcv_checksum(struct sk_buff *skb)struct sctp_input_cb {union {struct inet_skb_parm h4; -#if defined(CONFIG_IPV6 ) || defined (CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )struct inet6_skb_parm h6;#endif } header;
net/sctp/protocol.c +1 -1
@@ -637,7 +637,7 @@ void sctp_addr_wq_timeout_handler(unsigned long arg)" for cmd %d at entry %p\n" , &sctp_addr_waitq, &addrw->a, addrw->state, addrw); -#if defined(CONFIG_IPV6 ) || defined (CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )/* Now we send an ASCONF for each association */ /* Note. we currently don't handle link local IPv6 addressees */ if (addrw->a.sa.sa_family ==AF_INET6 ) {
net/sctp/socket.c +2 -2
@@ -6841,7 +6841,7 @@ struct proto sctp_prot = { .sockets_allocated = &sctp_sockets_allocated, }; -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )struct proto sctpv6_prot = { .name = "SCTPv6",
@@ -6872,4 +6872,4 @@ struct proto sctpv6_prot = { .memory_allocated = &sctp_memory_allocated, .sockets_allocated = &sctp_sockets_allocated, }; -#endif /* defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) */ +#endif /* IS_ENABLED(CONFIG_IPV6) */
net/sunrpc/addr.c +4 -4
@@ -21,7 +21,7 @@#include <linux/slab.h> #include <linux/export.h> -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )static size_t rpc_ntop6_noscopeid (const struct sockaddr *sap,char *buf,const int buflen)
@@ -91,7 +91,7 @@ static size_t rpc_ntop6(const struct sockaddr *sap, return len; } -#else /* !(defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)) */ +#else /* !IS_ENABLED(CONFIG_IPV6) */ static size_t rpc_ntop6_noscopeid (const struct sockaddr *sap,char *buf,const int buflen)
@@ -105,7 +105,7 @@ static size_t rpc_ntop6(const struct sockaddr *sap, return 0; } -#endif /* !(defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)) */ +#endif /* !IS_ENABLED(CONFIG_IPV6) */ static int rpc_ntop4 (const struct sockaddr *sap,char *buf,const size_t buflen)
@@ -155,7 +155,7 @@ static size_t rpc_pton4(const char *buf, const size_t buflen,return sizeof (struct sockaddr_in ); } -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )static int rpc_parse_scope_id (const char *buf,const size_t buflen,const char *delim,struct sockaddr_in6 *sin6) {
net/sunrpc/svc.c +4 -4
@@ -826,7 +826,7 @@ static int __svc_rpcb_register4(const u32 program, const u32 version,return error; } -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )/* * Register an "inet6" protocol family netid with the local * rpcbind daemon via an rpcbind v4 SET request.
@@ -872,7 +872,7 @@ static int __svc_rpcb_register6(const u32 program, const u32 version, return error; } -#endif /* defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) */ +#endif /* IS_ENABLED(CONFIG_IPV6) */ /* * Register a kernel RPC service via rpcbind version 4.
@@ -893,11 +893,11 @@ static int __svc_register(const char *progname, error =__svc_rpcb_register4 (program, version, protocol, port);break ; -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )case PF_INET6 : error =__svc_rpcb_register6 (program, version, protocol, port); -#endif /* defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) */ +#endif }if (error <0 )
net/sunrpc/svc_xprt.c +4 -4
@@ -179,13 +179,13 @@ static struct svc_xprt *__svc_xpo_create(struct svc_xprt_class *xcl, .sin_addr.s_addr = htonl(INADDR_ANY), .sin_port = htons(port), }; -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )struct sockaddr_in6 sin6 = { .sin6_family =AF_INET6 , .sin6_addr =IN6ADDR_ANY_INIT , .sin6_port =htons (port), }; -#endif /* defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) */ +#endif struct sockaddr *sap;size_t len;
@@ -194,12 +194,12 @@ static struct svc_xprt *__svc_xpo_create(struct svc_xprt_class *xcl, sap = (struct sockaddr *)&sin; len =sizeof (sin);break ; -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )case PF_INET6 : sap = (struct sockaddr *)&sin6; len =sizeof (sin6);break ; -#endif /* defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) */ +#endif default :return ERR_PTR (-EAFNOSUPPORT ); }
net/sunrpc/svcauth_unix.c +1 -1
@@ -220,7 +220,7 @@ static int ip_map_parse(struct cache_detail *cd,ipv6_addr_set_v4mapped (address.s4.sin_addr.s_addr, &sin6.sin6_addr);break ; -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )case AF_INET6 :memcpy (&sin6, &address.s6,sizeof (sin6));break ;
net/xfrm/xfrm_policy.c +3 -3
@@ -1340,7 +1340,7 @@ static inline struct xfrm_dst *xfrm_alloc_dst(struct net *net, int family)case AF_INET : dst_ops = &net->xfrm.xfrm4_dst_ops;break ; -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )case AF_INET6 : dst_ops = &net->xfrm.xfrm6_dst_ops;break ;
@@ -2435,7 +2435,7 @@ int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo)case AF_INET : xfrm_dst_ops = &net->xfrm.xfrm4_dst_ops;break ; -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )case AF_INET6 : xfrm_dst_ops = &net->xfrm.xfrm6_dst_ops;break ;
@@ -2485,7 +2485,7 @@ static void __net_init xfrm_dst_ops_init(struct net *net) afinfo = xfrm_policy_afinfo[AF_INET ];if (afinfo) net->xfrm.xfrm4_dst_ops = *afinfo->dst_ops; -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 ) afinfo = xfrm_policy_afinfo[AF_INET6 ];if (afinfo) net->xfrm.xfrm6_dst_ops = *afinfo->dst_ops;
net/xfrm/xfrm_user.c +6 -6
@@ -28,7 +28,7 @@#include <net/netlink.h> #include <net/ah.h> #include <asm/uaccess.h> -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )#include <linux/in6.h> #endif
@@ -150,7 +150,7 @@ static int verify_newsa_info(struct xfrm_usersa_info *p,break ;case AF_INET6 : -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )break ;#else err = -EAFNOSUPPORT ;
@@ -201,7 +201,7 @@ static int verify_newsa_info(struct xfrm_usersa_info *p, goto out;break ; -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )case IPPROTO_DSTOPTS :case IPPROTO_ROUTING : if (attrs[XFRMA_ALG_COMP] ||
@@ -1160,7 +1160,7 @@ static int verify_newpolicy_info(struct xfrm_userpolicy_info *p)break ;case AF_INET6 : -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )break ;#else return -EAFNOSUPPORT ;
@@ -1231,7 +1231,7 @@ static int validate_tmpl(int nr, struct xfrm_user_tmpl *ut, u16 family)switch (ut[i].family) {case AF_INET :break ; -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )case AF_INET6 :break ;#endif
@@ -2604,7 +2604,7 @@ static struct xfrm_policy *xfrm_compile_policy(struct sock *sk, int opt,return NULL ; }break ; -#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +#if IS_ENABLED (CONFIG_IPV6 )case AF_INET6 :if (opt !=IPV6_XFRM_POLICY ) { *dir = -EOPNOTSUPP ;
PATCH 1/1 drivers/net: use IS_ENABLED(CONFIG_IPV6)
Instead of testing defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
---
Here's the same for drivers/net/
drivers/net/ethernet/broadcom/cnic.c | 2 +- drivers/net/wireless/ipw2x00/ipw2100.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/broadcom/cnic.c +1 -1
@@ -3516,7 +3516,7 @@ static int cnic_get_v4_route(struct sockaddr_in *dst_addr,static int cnic_get_v6_route (struct sockaddr_in6 *dst_addr,struct dst_entry **dst) { -#if defined(CONFIG_IPV6 ) || (defined(CONFIG_IPV6_MODULE ) && defined(MODULE )) +#if IS_ENABLED (CONFIG_IPV6 )struct flowi6 fl6;memset (&fl6,0 ,sizeof (fl6));
drivers/net/wireless/ipw2x00/ipw2100.c +1 -1
@@ -4926,7 +4926,7 @@ static int ipw2100_system_config(struct ipw2100_priv *priv, int batch_mode)/* If IPv6 is configured in the kernel then we don't want to filter out all * of the multicast packets as IPv6 needs some. */ -#if !defined(CONFIG_IPV6 ) && !defined(CONFIG_IPV6_MODULE ) +#if !IS_ENABLED (CONFIG_IPV6 ) cmd.host_command =ADD_MULTICAST ; cmd.host_command_sequence =0 ; cmd.host_command_length =0 ;
Re: [PATCH net-next] drivers/net: use IS_ENABLED(CONFIG_IPV6)
Quoted 16 lines · Joe Perches
Instead of testing
defined(CONFIG_IPV6)||defined(CONFIG_IPV6_MODULE)Signed-off-by Joe Perches <[email protected]>---
Here's the same for
drivers/net/drivers/net/ethernet/broadcom/cnic.c | 2 +- drivers/net/wireless/ipw2x00/ipw2100.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)drivers/net/ethernet/broadcom/cnic.c +0
-0
drivers/net/ethernet/broadcom/cnic.c static int cnic_get_v4_route(struct sockaddr_in *dst_addr, · line 3519
Quoted 5 lines
drivers/net/ethernet/broadcom/cnic.c +1
-1@@ -3516,7 +3516,7 @@ static int cnic_get_v4_route(struct sockaddr_in *dst_addr,static int cnic_get_v6_route (struct sockaddr_in6 *dst_addr,struct dst_entry **dst) { -#if defined(CONFIG_IPV6 ) || (defined(CONFIG_IPV6_MODULE ) && defined(MODULE )) +#if IS_ENABLED (CONFIG_IPV6 )
Are you sure this is equivalent ?
Re: [PATCH net-next] drivers/net: use IS_ENABLED(CONFIG_IPV6)
Quoted 2 lines · Eric Dumazet
Quoted 1 line · Joe Perches
Instead of testing
defined(CONFIG_IPV6)||defined(CONFIG_IPV6_MODULE)
[]
Quoted 1 line
drivers/net/ethernet/broadcom/cnic.c
Quoted 1 line
drivers/net/ethernet/broadcom/cnic.c +0
-0
[]
Quoted 8 lines
drivers/net/ethernet/broadcom/cnic.c static int cnic_get_v4_route(struct sockaddr_in *dst_addr, · line 3519
Quoted 6 lines
drivers/net/ethernet/broadcom/cnic.c +1
-1@@ -3516,7 +3516,7 @@ static int cnic_get_v4_route(struct sockaddr_in *dst_addr,static int cnic_get_v6_route (struct sockaddr_in6 *dst_addr,struct dst_entry **dst) { -#if defined(CONFIG_IPV6 ) || (defined(CONFIG_IPV6_MODULE ) && defined(MODULE )) +#if IS_ENABLED (CONFIG_IPV6 )Are you sure this is equivalent ?
I believe so.
KBUILD add -DMODULE to the compile options when
building for modules.
Re: [PATCH net-next] drivers/net: use IS_ENABLED(CONFIG_IPV6)
Quoted 15 lines · Joe Perches
Quoted 2 lines · Eric Dumazet
Quoted 1 line · Joe Perches
Instead of testing
defined(CONFIG_IPV6)||defined(CONFIG_IPV6_MODULE)[]
Quoted 1 line
drivers/net/ethernet/broadcom/cnic.c
Quoted 1 line
drivers/net/ethernet/broadcom/cnic.c +0
-0[]
Quoted 8 lines
drivers/net/ethernet/broadcom/cnic.c static int cnic_get_v4_route(struct sockaddr_in *dst_addr, · line 3519
Quoted 6 lines
drivers/net/ethernet/broadcom/cnic.c +1
-1@@ -3516,7 +3516,7 @@ static int cnic_get_v4_route(struct sockaddr_in *dst_addr,static int cnic_get_v6_route (struct sockaddr_in6 *dst_addr,struct dst_entry **dst) { -#if defined(CONFIG_IPV6 ) || (defined(CONFIG_IPV6_MODULE ) && defined(MODULE )) +#if IS_ENABLED (CONFIG_IPV6 )Are you sure this is equivalent ?
Quoted 6 lines
I believe so.
KBUILD add -DMODULE to the compile options when
building for modules.
You didnt answer my question or you dont understand your change.
I wonder why.
Point was : IPV6 compiled as a module, and _this_ driver compiled staticaly.
Did you tried this combination ?
Re: [PATCH net-next] drivers/net: use IS_ENABLED(CONFIG_IPV6)
Quoted 7 lines · Eric Dumazet
Quoted 4 lines · Joe Perches
Quoted 2 lines · Eric Dumazet
Le samedi 10 décembre 2011 à 14:00 -0800, Joe Perches a écrit :
Are you sure this is equivalent ?I believe so.
You didnt answer my question or you dont understand your change. I wonder why.
I believe "I believe so" is an answer. Perhaps not a good or in this case perhaps even an answer with an incorrect result, but still an answer...
Quoted 3 lines
Point was : IPV6 compiled as a module, and _this_ driver compiled staticaly.
Did you tried this combination ?
No, though I will try it this week.
cheers, Joe
Re: [PATCH net-next] net: use IS_ENABLED(CONFIG_IPV6)
In reply to Eric DumazetFrom: Eric Dumazet <[email protected]>
Date: Sat, 10 Dec 2011 20:48:31 +0100
Quoted 4 lines
Instead of testing
defined(CONFIG_IPV6)||defined(CONFIG_IPV6_MODULE)Signed-off-by Eric Dumazet <[email protected]>
Applied.
Re: [PATCH 1/2] udp_diag: Make it module when ipv6 is a module
In reply to Pavel EmelyanovQuoted 20 lines · Pavel Emelyanov
Eric Dumazet reported, that when
inet_diagis built-in theudp_diagalso goes built-in and when ipv6 is a module the udp6 lookup symbol is not found.LD .tmp_vmlinux1
net/built-in.o: In function `udp_dump_one':
udp_diag.c:(.text+0xa2b40): undefined reference to `__udp6_lib_lookup'
make: *** [.tmp_vmlinux1] Erreur 1Fix this by making udp diag build mode depend on both -- inet diag and ipv6.
Reported-by Eric Dumazet <[email protected]>Signed-off-by Pavel Emelyanov <[email protected]>---
net/ipv4/Kconfig +0
-0
net/ipv4/Kconfig config INET_TCP_DIAG · line 417
Quoted 8 lines
net/ipv4/Kconfig +1
-1@@ -411,7 +411,7 @@ config INET_TCP_DIAG config INET_UDP_DIAG depends on INET_DIAG - def_tristate INET_DIAG + def_tristate INET_DIAG && IPV6 menuconfig TCP_CONG_ADVANCED bool "TCP: advanced congestion control"
Thanks !
Re: [PATCH 1/2] udp_diag: Make it module when ipv6 is a module
From: Eric Dumazet <[email protected]>
Date: Sat, 10 Dec 2011 12:00:20 +0100
Quoted 13 lines · Pavel Emelyanov
Quoted 12 lines
Eric Dumazet reported, that when
inet_diagis built-in theudp_diagalso goes built-in and when ipv6 is a module the udp6 lookup symbol is not found.LD .tmp_vmlinux1
net/built-in.o: In function `udp_dump_one':
udp_diag.c:(.text+0xa2b40): undefined reference to `__udp6_lib_lookup'
make: *** [.tmp_vmlinux1] Erreur 1Fix this by making udp diag build mode depend on both -- inet diag and ipv6.
Reported-by Eric Dumazet <[email protected]>Signed-off-by Pavel Emelyanov <[email protected]>
...
Quoted 2 lines
Acked-by Eric Dumazet <[email protected]>
Applied.
PATCH 12/13 udp_diag: Implement the dump-all functionality
In reply to Pavel EmelyanovDo the same as TCP does -- iterate the given udp_table, filter sockets with bytecode and dump sockets into reply message.
The same filtering as for TCP applies, though only some of the state bits really matter.
--- net/ipv4/udp_diag.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 54 insertions(+), 0 deletions(-)
net/ipv4/udp_diag.c +54 -0
@@ -18,6 +18,17 @@#include <linux/inet_diag.h> #include <linux/sock_diag.h> +static int sk_diag_dump (struct sock *sk,struct sk_buff *skb, +struct netlink_callback *cb,struct inet_diag_req *req, +struct nlattr *bc) +{ +if (!inet_diag_bc_sk (bc, sk)) +return 0 ; + +return inet_sk_diag_fill (sk,NULL , skb, req,NETLINK_CB (cb->skb).pid, + cb->nlh->nlmsg_seq,NLM_F_MULTI , cb->nlh); +} +static int udp_dump_one (struct udp_table *tbl,struct sk_buff *in_skb,const struct nlmsghdr *nlh,struct inet_diag_req *req) {
@@ -77,6 +88,49 @@ out_nosk:static void udp_dump (struct udp_table *table,struct sk_buff *skb,struct netlink_callback *cb,struct inet_diag_req *r,struct nlattr *bc) { +int num, s_num, slot, s_slot; + + s_slot = cb->args[0 ]; + num = s_num = cb->args[1 ]; + +for (slot = s_slot; slot <= table->mask; num = s_num =0 , slot++) { +struct sock *sk; +struct hlist_nulls_node *node; +struct udp_hslot *hslot = &table->hash[slot]; + +if (hlist_nulls_empty (&hslot->head)) +continue ; + +spin_lock_bh (&hslot->lock); +sk_nulls_for_each (sk, node, &hslot->head) { +struct inet_sock *inet =inet_sk (sk); + +if (num < s_num) + goto next; +if (!(r->idiag_states & (1 << sk->sk_state))) + goto next; +if (r->sdiag_family !=AF_UNSPEC && + sk->sk_family != r->sdiag_family) + goto next; +if (r->id.idiag_sport != inet->inet_sport && + r->id.idiag_sport) + goto next; +if (r->id.idiag_dport != inet->inet_dport && + r->id.idiag_dport) + goto next; + +if (sk_diag_dump (sk, skb, cb, r, bc) <0 ) { +spin_unlock_bh (&hslot->lock); + goto done; + } +next: + num++; + } +spin_unlock_bh (&hslot->lock); + } +done: + cb->args[0 ] = slot; + cb->args[1 ] = num; } static void udp_diag_dump(struct sk_buff *skb, struct netlink_callback *cb,
Signature · 1 line
1.5.5.6
PATCH 13/13 udp_diag: Wire the udp_diag module into kbuild
In reply to Pavel EmelyanovCopy-s/tcp/udp/-paste from TCP bits.
--- net/ipv4/Kconfig | 4 ++++ net/ipv4/Makefile | 1 + 2 files changed, 5 insertions(+), 0 deletions(-)
net/ipv4/Kconfig +4 -0
@@ -409,6 +409,10 @@ config INET_TCP_DIAG depends on INET_DIAG def_tristate INET_DIAG +config INET_UDP_DIAG + depends on INET_DIAG + def_tristate INET_DIAG + menuconfig TCP_CONG_ADVANCED bool "TCP: advanced congestion control" ---help---
net/ipv4/Makefile +1 -0
@@ -34,6 +34,7 @@ obj-$(CONFIG_IP_PNP) += ipconfig.o obj-$(CONFIG_NETFILTER) += netfilter.o netfilter/ obj-$(CONFIG_INET_DIAG) += inet_diag.o obj-$(CONFIG_INET_TCP_DIAG) += tcp_diag.o +obj-$(CONFIG_INET_UDP_DIAG) += udp_diag.o obj-$(CONFIG_NET_TCPPROBE) += tcp_probe.o obj-$(CONFIG_TCP_CONG_BIC) += tcp_bic.o obj-$(CONFIG_TCP_CONG_CUBIC) += tcp_cubic.o
Signature · 1 line
1.5.5.6
PATCH 1/1 iproute: Dump UDP sockets via netlink
In reply to Pavel EmelyanovSince for UDP the same binary API is used, just rename tcp_show_netlink and others into inet_show_netlink (and others) and wire the calls into udp-related paths.
Applies on top of previous patch with support for the new sock_diag api.
---
misc/ss.c +27 -12
@@ -1410,7 +1410,7 @@ } } -static int tcp_show_sock (struct nlmsghdr *nlh,struct filter *f) +static int inet_show_sock (struct nlmsghdr *nlh,struct filter *f) {struct inet_diag_msg *r =NLMSG_DATA (nlh);struct tcpstat s;
@@ -1474,7 +1474,7 @@return 0 ; } -static int __tcp_show_netlink (struct filter *f,FILE *dump_fp,int family,int socktype) +static int __inet_show_netlink (struct filter *f,FILE *dump_fp,int family,int socktype) {int fd;struct sockaddr_nl nladdr;
@@ -1590,7 +1590,7 @@return 0 ; }if (!dump_fp) { - err =tcp_show_sock (h,NULL ); + err =inet_show_sock (h,NULL );if (err <0 )return err; }
@@ -1610,19 +1610,19 @@return 0 ; } -static int tcp_show_netlink (struct filter *f,FILE *dump_fp,int socktype) +static int inet_show_netlink (struct filter *f,FILE *dump_fp,int socktype) {int err =0 ;if (f->families & (1 <<AF_INET )) - err |=__tcp_show_netlink (f, dump_fp,AF_INET , socktype); + err |=__inet_show_netlink (f, dump_fp,AF_INET , socktype);if (f->families & (1 <<AF_INET6 )) - err |=__tcp_show_netlink (f, dump_fp,AF_INET6 , socktype); + err |=__inet_show_netlink (f, dump_fp,AF_INET6 , socktype);return err; } -static int tcp_show_netlink_file (struct filter *f) +static int inet_show_netlink_file (struct filter *f) {FILE *fp;char buf[8192 ];
@@ -1672,7 +1672,7 @@return -1 ; } - err =tcp_show_sock (h, f); + err =inet_show_sock (h, f);if (err <0 )return err; }
@@ -1687,10 +1687,10 @@ dg_proto =TCP_PROTO ;if (getenv ("TCPDIAG_FILE" )) -return tcp_show_netlink_file (f); +return inet_show_netlink_file (f);if (!getenv ("PROC_NET_TCP" ) && !getenv ("PROC_ROOT" ) - &&tcp_show_netlink (f,NULL , socktype) ==0 ) + &&inet_show_netlink (f,NULL , socktype) ==0 )return 0 ;/* Sigh... We have to parse /proc/net/tcp... */
@@ -1852,6 +1852,15 @@ {FILE *fp =NULL ; +if (getenv ("TCPDIAG_FILE" )) +return inet_show_netlink_file (f); + +if (!getenv ("PROC_NET_TCP" ) && !getenv ("PROC_ROOT" ) + &&inet_show_netlink (f,NULL ,IPPROTO_UDP ) ==0 ) +return 0 ; + +/* legacy proc files parse */ + dg_proto =UDP_PROTO ;if (f->families&(1 <<AF_INET )) {
@@ -2787,7 +2796,7 @@if (dump_tcpdiag) {FILE *dump_fp = stdout; -if (!(current_filter.dbs & (1 <<TCP_DB ))) { +if (!(current_filter.dbs & ((1 <<TCP_DB ) | (1 <<UDP_DB )))) {fprintf (stderr,"ss: tcpdiag dump requested and no tcp in filter.\n" );exit (0 ); }
@@ -2798,7 +2807,13 @@exit (-1 ); } } -tcp_show_netlink (¤t_filter, dump_fp,IPPROTO_TCP ); + +if (current_filter.dbs & (1 <<UDP_DB )) +inet_show_netlink (¤t_filter, dump_fp,IPPROTO_UDP ); + +if (current_filter.dbs & (1 <<TCP_DB )) +inet_show_netlink (¤t_filter, dump_fp,IPPROTO_TCP ); +fflush (dump_fp);exit (0 ); }
David Miller
maintainerFrom: Pavel Emelyanov <[email protected]>
Date: Fri, 09 Dec 2011 20:20:49 +0400
Quoted 3 lines
This is an extension of
inet_diagmodule and the newudp_diagone. Plus the patch for iproute's ss to dump udp sockets via netlink (applies on top of previous patch for newNETLINK_SOCK_DIAGAPI [1]).
I like it :-) All applied, thanks!