MIB: add struct net to ICMP accounting macros
Subsystems (6)
cover MIB: add struct net to ICMP accounting macros
Step #2. This is almost as easy as the UDP case, but requires some preparation to have a struct net at hands in some places.
David, there are (mainly) NET, TCP and IP(6) stats left and I planned to send them step-by-step with small series (and plus the closing one with SNMP_XXX macros, etc). But if you prefer seeing one large set instead of several small ones just let me know ;)
PATCH 1/7 ICMP: add struct net argument to icmp_out_count
This routine deals with ICMP statistics, but doesn't have a struct net at hands, so add one.
--- include/net/icmp.h | 3 ++- net/ipv4/icmp.c | 2 +- net/ipv4/ip_output.c | 3 ++- net/ipv4/raw.c | 3 ++- 4 files changed, 7 insertions(+), 4 deletions(-)
include/net/icmp.h +2 -1
@@ -44,12 +44,13 @@ DECLARE_SNMP_STAT(struct icmpmsg_mib, icmpmsg_statistics);struct dst_entry ;struct net_proto_family ;struct sk_buff ; +struct net ;extern void icmp_send (struct sk_buff *skb_in,int type,int code,__be32 info);extern int icmp_rcv (struct sk_buff *skb);extern int icmp_ioctl (struct sock *sk,int cmd,unsigned long arg);extern int icmp_init (void ); -extern void icmp_out_count (unsigned char type); +extern void icmp_out_count (struct net *net,unsigned char type);/* Move into dst.h ? */ extern int xrlim_allow (struct dst_entry *dst,int timeout);
net/ipv4/icmp.c +1 -1
@@ -296,7 +296,7 @@ out:/* * Maintain the counters used in the SNMP statistics for outgoing ICMP */ -void icmp_out_count (unsigned char type) +void icmp_out_count (struct net *net,unsigned char type) {ICMPMSGOUT_INC_STATS (type);ICMP_INC_STATS (ICMP_MIB_OUTMSGS );
net/ipv4/ip_output.c +2 -1
@@ -1211,6 +1211,7 @@ int ip_push_pending_frames(struct sock *sk)struct sk_buff *skb, *tmp_skb;struct sk_buff **tail_skb;struct inet_sock *inet =inet_sk (sk); +struct net *net =sock_net (sk);struct ip_options *opt =NULL ;struct rtable *rt = (struct rtable *)inet->cork.dst;struct iphdr *iph;
@@ -1280,7 +1281,7 @@ int ip_push_pending_frames(struct sock *sk) skb->dst =dst_clone (&rt->u.dst);if (iph->protocol ==IPPROTO_ICMP ) -icmp_out_count (((struct icmphdr *) +icmp_out_count (net, ((struct icmphdr *)skb_transport_header (skb))->type);/* Netfilter gets whole the not fragmented skb. */
net/ipv4/raw.c +2 -1
@@ -320,6 +320,7 @@ static int raw_send_hdrinc(struct sock *sk, void *from, size_t length, unsigned int flags) {struct inet_sock *inet =inet_sk (sk); +struct net *net =sock_net (sk);struct iphdr *iph;struct sk_buff *skb;unsigned int iphlen;
@@ -368,7 +369,7 @@ static int raw_send_hdrinc(struct sock *sk, void *from, size_t length, iph->check =ip_fast_csum ((unsigned char *)iph, iph->ihl); }if (iph->protocol ==IPPROTO_ICMP ) -icmp_out_count (((struct icmphdr *) +icmp_out_count (net, ((struct icmphdr *)skb_transport_header (skb))->type); err = NF_HOOK(PF_INET, NF_INET_LOCAL_OUT, skb, NULL, rt->u.dst.dev,
Signature · 1 line
1.5.3.4
Re: [PATCH net-next 1/7] ICMP: add struct net argument to icmp_out_count
From: Pavel Emelyanov <[email protected]>
Date: Mon, 07 Jul 2008 14:44:06 +0400
Quoted 4 lines
This routine deals with ICMP statistics, but doesn't have a struct net at hands, so add one.
Signed-off-by Pavel Emelyanov <[email protected]>
Applied.
Please use lowercase subsystem names in commit header lines in the future, I fixed it up this time.
Thanks!
PATCH 2/7 INET: toss struct net initialization around
In reply to Pavel EmelyanovSome places, that deal with ICMP statistics already have where to get a struct net from, but use it directly, without declaring a separate variable on the stack.
Since I will need this net soon, I declare a struct net on the stack and use it in the existing places in a separate patch not to spoil the future ones.
--- net/dccp/ipv4.c | 3 ++- net/ipv4/icmp.c | 4 +--- net/ipv4/tcp_ipv4.c | 3 ++- net/ipv4/udp.c | 3 ++- 4 files changed, 7 insertions(+), 6 deletions(-)
net/dccp/ipv4.c +2 -1
@@ -205,13 +205,14 @@ static void dccp_v4_err(struct sk_buff *skb, u32 info)struct sock *sk;__u64 seq;int err; +struct net *net =dev_net (skb->dev);if (skb->len < (iph->ihl <<2 ) +8 ) {ICMP_INC_STATS_BH (ICMP_MIB_INERRORS );return ; } - sk =inet_lookup (dev_net (skb->dev), &dccp_hashinfo, + sk =inet_lookup (net, &dccp_hashinfo, iph->daddr, dh->dccph_dport, iph->saddr, dh->dccph_sport,inet_iif (skb));if (sk ==NULL ) {
net/ipv4/icmp.c +1 -3
@@ -973,6 +973,7 @@ int icmp_rcv(struct sk_buff *skb) {struct icmphdr *icmph;struct rtable *rt = skb->rtable; +struct net *net =dev_net (rt->u.dst.dev);if (!xfrm4_policy_check (NULL ,XFRM_POLICY_IN , skb)) {int nh;
@@ -1027,9 +1028,6 @@ int icmp_rcv(struct sk_buff *skb)*/ if (rt->rt_flags & (RTCF_BROADCAST |RTCF_MULTICAST )) { -struct net *net; - - net =dev_net (rt->u.dst.dev);/* * RFC 1122: 3.2.2.6 An ICMP_ECHO to broadcast MAY be * silently ignored (we let user decide with a sysctl).
net/ipv4/tcp_ipv4.c +2 -1
@@ -343,13 +343,14 @@ void tcp_v4_err(struct sk_buff *skb, u32 info)struct sock *sk;__u32 seq;int err; +struct net *net =dev_net (skb->dev);if (skb->len < (iph->ihl <<2 ) +8 ) {ICMP_INC_STATS_BH (ICMP_MIB_INERRORS );return ; } - sk =inet_lookup (dev_net (skb->dev), &tcp_hashinfo, iph->daddr, th->dest, + sk =inet_lookup (net, &tcp_hashinfo, iph->daddr, th->dest, iph->saddr, th->source,inet_iif (skb));if (!sk) {ICMP_INC_STATS_BH (ICMP_MIB_INERRORS );
net/ipv4/udp.c +2 -1
@@ -354,8 +354,9 @@ void __udp4_lib_err(struct sk_buff *skb, u32 info, struct hlist_head udptable[])struct sock *sk;int harderr;int err; +struct net *net =dev_net (skb->dev); - sk =__udp4_lib_lookup (dev_net (skb->dev), iph->daddr, uh->dest, + sk =__udp4_lib_lookup (net, iph->daddr, uh->dest, iph->saddr, uh->source, skb->dev->ifindex, udptable);if (sk ==NULL ) {ICMP_INC_STATS_BH (ICMP_MIB_INERRORS );
Signature · 1 line
1.5.3.4
Re: [PATCH net-next 2/7] INET: toss struct net initialization around
From: Pavel Emelyanov <[email protected]>
Date: Mon, 07 Jul 2008 14:47:16 +0400
Quoted 9 lines
Some places, that deal with ICMP statistics already have where to get a struct net from, but use it directly, without declaring a separate variable on the stack.
Since I will need this net soon, I declare a struct net on the stack and use it in the existing places in a separate patch not to spoil the future ones.
Signed-off-by Pavel Emelyanov <[email protected]>
Applied.
PATCH 3/7 ICMP: drop unused MIB accounting wrappers
In reply to Pavel EmelyanovThere are ICMP_XXX_STATS that are not used in the kernel, so I remove them, not to "just patch" them later. But if there's some sense in keeping them, kick me - I will remake this set keeping them.
--- include/net/icmp.h | 5 ----- 1 files changed, 0 insertions(+), 5 deletions(-)
include/net/icmp.h +0 -5
@@ -33,13 +33,8 @@ DECLARE_SNMP_STAT(struct icmp_mib, icmp_statistics); DECLARE_SNMP_STAT(struct icmpmsg_mib, icmpmsg_statistics);#define ICMP_INC_STATS (field) SNMP_INC_STATS(icmp_statistics, field)#define ICMP_INC_STATS_BH (field) SNMP_INC_STATS_BH(icmp_statistics, field) -#define ICMP_INC_STATS_USER (field) SNMP_INC_STATS_USER(icmp_statistics, field)#define ICMPMSGOUT_INC_STATS (field) SNMP_INC_STATS(icmpmsg_statistics, field+256) -#define ICMPMSGOUT_INC_STATS_BH (field) SNMP_INC_STATS_BH(icmpmsg_statistics, field+256) -#define ICMPMSGOUT_INC_STATS_USER (field) SNMP_INC_STATS_USER(icmpmsg_statistics, field+256) -#define ICMPMSGIN_INC_STATS (field) SNMP_INC_STATS(icmpmsg_statistics, field)#define ICMPMSGIN_INC_STATS_BH (field) SNMP_INC_STATS_BH(icmpmsg_statistics, field) -#define ICMPMSGIN_INC_STATS_USER (field) SNMP_INC_STATS_USER(icmpmsg_statistics, field)struct dst_entry ;struct net_proto_family ;
Signature · 1 line
1.5.3.4
Re: [PATCH net-next 3/7] ICMP: drop unused MIB accounting wrappers
From: Pavel Emelyanov <[email protected]>
Date: Mon, 07 Jul 2008 14:50:38 +0400
Quoted 5 lines
There are
ICMP_XXX_STATSthat are not used in the kernel, so I remove them, not to "just patch" them later. But if there's some sense in keeping them, kick me - I will remake this set keeping them.Signed-off-by Pavel Emelyanov <[email protected]>
Applied.
PATCH 4/7 MIB: add struct net to ICMP_INC_STATS
In reply to Pavel Emelyanov--- include/net/icmp.h | 2 +- net/ipv4/icmp.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
include/net/icmp.h +1 -1
@@ -31,7 +31,7 @@ struct icmp_err {extern struct icmp_err icmp_err_convert[]; DECLARE_SNMP_STAT(struct icmp_mib, icmp_statistics); DECLARE_SNMP_STAT(struct icmpmsg_mib, icmpmsg_statistics); -#define ICMP_INC_STATS (field) SNMP_INC_STATS(icmp_statistics, field) +#define ICMP_INC_STATS (net, field) SNMP_INC_STATS(icmp_statistics, field)#define ICMP_INC_STATS_BH (field) SNMP_INC_STATS_BH(icmp_statistics, field)#define ICMPMSGOUT_INC_STATS (field) SNMP_INC_STATS(icmpmsg_statistics, field+256)#define ICMPMSGIN_INC_STATS_BH (field) SNMP_INC_STATS_BH(icmpmsg_statistics, field)
net/ipv4/icmp.c +1 -1
@@ -299,7 +299,7 @@ out:void icmp_out_count (struct net *net,unsigned char type) {ICMPMSGOUT_INC_STATS (type); -ICMP_INC_STATS (ICMP_MIB_OUTMSGS ); +ICMP_INC_STATS (net,ICMP_MIB_OUTMSGS ); }/*
Signature · 1 line
1.5.3.4
Re: [PATCH net-next 4/7] MIB: add struct net to ICMP_INC_STATS
From: Pavel Emelyanov <[email protected]>
Date: Mon, 07 Jul 2008 14:51:24 +0400
Quoted 1 line
Signed-off-by Pavel Emelyanov <[email protected]>
Applied.
PATCH 5/7 MIB: add struct net to ICMP_INC_STATS_BH
In reply to Pavel Emelyanov--- include/net/icmp.h | 2 +- net/dccp/ipv4.c | 4 ++-- net/ipv4/icmp.c | 10 +++++----- net/ipv4/tcp_ipv4.c | 4 ++-- net/ipv4/udp.c | 2 +- net/sctp/input.c | 5 +++-- 6 files changed, 14 insertions(+), 13 deletions(-)
include/net/icmp.h +1 -1
@@ -32,7 +32,7 @@ extern struct icmp_err icmp_err_convert[]; DECLARE_SNMP_STAT(struct icmp_mib, icmp_statistics); DECLARE_SNMP_STAT(struct icmpmsg_mib, icmpmsg_statistics);#define ICMP_INC_STATS (net, field) SNMP_INC_STATS(icmp_statistics, field) -#define ICMP_INC_STATS_BH (field) SNMP_INC_STATS_BH(icmp_statistics, field) +#define ICMP_INC_STATS_BH (net, field) SNMP_INC_STATS_BH(icmp_statistics, field)#define ICMPMSGOUT_INC_STATS (field) SNMP_INC_STATS(icmpmsg_statistics, field+256)#define ICMPMSGIN_INC_STATS_BH (field) SNMP_INC_STATS_BH(icmpmsg_statistics, field)
net/dccp/ipv4.c +2 -2
@@ -208,7 +208,7 @@ static void dccp_v4_err(struct sk_buff *skb, u32 info)struct net *net =dev_net (skb->dev);if (skb->len < (iph->ihl <<2 ) +8 ) { -ICMP_INC_STATS_BH (ICMP_MIB_INERRORS ); +ICMP_INC_STATS_BH (net,ICMP_MIB_INERRORS );return ; }
@@ -216,7 +216,7 @@ static void dccp_v4_err(struct sk_buff *skb, u32 info) iph->daddr, dh->dccph_dport, iph->saddr, dh->dccph_sport, inet_iif(skb));if (sk ==NULL ) { -ICMP_INC_STATS_BH (ICMP_MIB_INERRORS ); +ICMP_INC_STATS_BH (net,ICMP_MIB_INERRORS );return ; }
net/ipv4/icmp.c +5 -5
@@ -763,7 +763,7 @@ static void icmp_unreach(struct sk_buff *skb) out:return ; out_err: -ICMP_INC_STATS_BH (ICMP_MIB_INERRORS ); +ICMP_INC_STATS_BH (net,ICMP_MIB_INERRORS ); goto out; }
@@ -803,7 +803,7 @@ static void icmp_redirect(struct sk_buff *skb) out:return ; out_err: -ICMP_INC_STATS_BH (ICMP_MIB_INERRORS ); +ICMP_INC_STATS_BH (dev_net (skb->dev),ICMP_MIB_INERRORS ); goto out; }
@@ -874,7 +874,7 @@ static void icmp_timestamp(struct sk_buff *skb) out:return ; out_err: -ICMP_INC_STATS_BH (ICMP_MIB_INERRORS ); +ICMP_INC_STATS_BH (dev_net (skb->dst->dev),ICMP_MIB_INERRORS ); goto out; }
@@ -994,7 +994,7 @@ int icmp_rcv(struct sk_buff *skb)skb_set_network_header (skb, nh); } -ICMP_INC_STATS_BH (ICMP_MIB_INMSGS ); +ICMP_INC_STATS_BH (net,ICMP_MIB_INMSGS );switch (skb->ip_summed) {case CHECKSUM_COMPLETE :
@@ -1053,7 +1053,7 @@ drop:kfree_skb (skb);return 0 ; error: -ICMP_INC_STATS_BH (ICMP_MIB_INERRORS ); +ICMP_INC_STATS_BH (net,ICMP_MIB_INERRORS ); goto drop; }
net/ipv4/tcp_ipv4.c +2 -2
@@ -346,14 +346,14 @@ void tcp_v4_err(struct sk_buff *skb, u32 info)struct net *net =dev_net (skb->dev);if (skb->len < (iph->ihl <<2 ) +8 ) { -ICMP_INC_STATS_BH (ICMP_MIB_INERRORS ); +ICMP_INC_STATS_BH (net,ICMP_MIB_INERRORS );return ; } sk =inet_lookup (net, &tcp_hashinfo, iph->daddr, th->dest, iph->saddr, th->source,inet_iif (skb));if (!sk) { -ICMP_INC_STATS_BH (ICMP_MIB_INERRORS ); +ICMP_INC_STATS_BH (net,ICMP_MIB_INERRORS );return ; }if (sk->sk_state ==TCP_TIME_WAIT ) {
net/ipv4/udp.c +1 -1
@@ -359,7 +359,7 @@ void __udp4_lib_err(struct sk_buff *skb, u32 info, struct hlist_head udptable[]) sk =__udp4_lib_lookup (net, iph->daddr, uh->dest, iph->saddr, uh->source, skb->dev->ifindex, udptable);if (sk ==NULL ) { -ICMP_INC_STATS_BH (ICMP_MIB_INERRORS ); +ICMP_INC_STATS_BH (net,ICMP_MIB_INERRORS );return ;/* No socket for error */ }
net/sctp/input.c +3 -2
@@ -61,6 +61,7 @@#include <net/sctp/sctp.h> #include <net/sctp/sm.h> #include <net/sctp/checksum.h> +#include <net/net_namespace.h> /* Forward declarations for internal helpers. */ static int sctp_rcv_ootb (struct sk_buff *);
@@ -534,7 +535,7 @@ void sctp_v4_err(struct sk_buff *skb, __u32 info)int err;if (skb->len < ihlen +8 ) { -ICMP_INC_STATS_BH (ICMP_MIB_INERRORS ); +ICMP_INC_STATS_BH (&init_net,ICMP_MIB_INERRORS );return ; }
@@ -548,7 +549,7 @@ void sctp_v4_err(struct sk_buff *skb, __u32 info) skb->network_header = saveip; skb->transport_header = savesctp;if (!sk) { -ICMP_INC_STATS_BH (ICMP_MIB_INERRORS ); +ICMP_INC_STATS_BH (&init_net,ICMP_MIB_INERRORS );return ; }/* Warning: The sock lock is held. Remember to call
Signature · 1 line
1.5.3.4
Re: [PATCH net-next 5/7] MIB: add struct net to ICMP_INC_STATS_BH
From: Pavel Emelyanov <[email protected]>
Date: Mon, 07 Jul 2008 14:52:19 +0400
Quoted 1 line
Signed-off-by Pavel Emelyanov <[email protected]>
Applied.
PATCH 6/7 MIB: add struct net to ICMPMSGOUT_INC_STATS
In reply to Pavel Emelyanov--- include/net/icmp.h | 2 +- net/ipv4/icmp.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
include/net/icmp.h +1 -1
@@ -33,7 +33,7 @@ DECLARE_SNMP_STAT(struct icmp_mib, icmp_statistics); DECLARE_SNMP_STAT(struct icmpmsg_mib, icmpmsg_statistics);#define ICMP_INC_STATS (net, field) SNMP_INC_STATS(icmp_statistics, field)#define ICMP_INC_STATS_BH (net, field) SNMP_INC_STATS_BH(icmp_statistics, field) -#define ICMPMSGOUT_INC_STATS (field) SNMP_INC_STATS(icmpmsg_statistics, field+256) +#define ICMPMSGOUT_INC_STATS (net, field) SNMP_INC_STATS(icmpmsg_statistics, field+256)#define ICMPMSGIN_INC_STATS_BH (field) SNMP_INC_STATS_BH(icmpmsg_statistics, field)struct dst_entry ;
net/ipv4/icmp.c +1 -1
@@ -298,7 +298,7 @@ out:*/ void icmp_out_count (struct net *net,unsigned char type) { -ICMPMSGOUT_INC_STATS (type); +ICMPMSGOUT_INC_STATS (net, type);ICMP_INC_STATS (net,ICMP_MIB_OUTMSGS ); }
Signature · 1 line
1.5.3.4
Re: [PATCH net-next 6/7] MIB: add struct net to ICMPMSGOUT_INC_STATS
From: Pavel Emelyanov <[email protected]>
Date: Mon, 07 Jul 2008 14:53:02 +0400
Quoted 1 line
Signed-off-by Pavel Emelyanov <[email protected]>
Applied.
PATCH 7/7 MIB: add struct net to ICMPMSGIN_INC_STATS_BH
In reply to Pavel Emelyanov--- include/net/icmp.h | 2 +- net/ipv4/icmp.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
include/net/icmp.h +1 -1
@@ -34,7 +34,7 @@ DECLARE_SNMP_STAT(struct icmpmsg_mib, icmpmsg_statistics);#define ICMP_INC_STATS (net, field) SNMP_INC_STATS(icmp_statistics, field)#define ICMP_INC_STATS_BH (net, field) SNMP_INC_STATS_BH(icmp_statistics, field)#define ICMPMSGOUT_INC_STATS (net, field) SNMP_INC_STATS(icmpmsg_statistics, field+256) -#define ICMPMSGIN_INC_STATS_BH (field) SNMP_INC_STATS_BH(icmpmsg_statistics, field) +#define ICMPMSGIN_INC_STATS_BH (net, field) SNMP_INC_STATS_BH(icmpmsg_statistics, field)struct dst_entry ;struct net_proto_family ;
net/ipv4/icmp.c +1 -1
@@ -1012,7 +1012,7 @@ int icmp_rcv(struct sk_buff *skb) icmph =icmp_hdr (skb); -ICMPMSGIN_INC_STATS_BH (icmph->type); +ICMPMSGIN_INC_STATS_BH (net, icmph->type);/* * 18 is the highest 'known' ICMP type. Anything else is a mystery *
Signature · 1 line
1.5.3.4
David Miller
maintainerRe: [PATCH net-next 7/7] MIB: add struct net to ICMPMSGIN_INC_STATS_BH
From: Pavel Emelyanov <[email protected]>
Date: Mon, 07 Jul 2008 14:53:44 +0400
Quoted 1 line
Signed-off-by Pavel Emelyanov <[email protected]>
Also applied, thanks a lot.