dump interface IPv6 multicast/anycast addresses through netlink
Subsystems (4)
PATCH 1/1 dump interface IPv6 multicast/anycast addresses through netlink
This patch is against Linux 2.6.4 kernel. It has been tested, 'ip' utility works fine. This patch is used by IPv6 MIBs.
Signature · 3 lines
Thanks Shirley Ma IBM Linux Technology Center
include/linux/rtnetlink.h +12 -1
@@ -47,7 +47,13 @@#define RTM_NEWPREFIX (RTM_BASE+36)#define RTM_GETPREFIX (RTM_BASE+38) -#define RTM_MAX (RTM_BASE+39) +#define RTM_NEWMULTICAST (RTM_BASE+40) +#define RTM_GETMULTICAST (RTM_BASE+42) + +#define RTM_NEWANYCAST (RTM_BASE+44) +#define RTM_GETANYCAST (RTM_BASE+46) + +#define RTM_MAX (RTM_BASE+47)/* Generic structure for encapsulation of optional route information.
@@ -339,6 +345,7 @@IFA_LOCAL ,IFA_LABEL ,IFA_BROADCAST , +IFA_MULTICAST ,IFA_ANYCAST , IFA_CACHEINFO };
@@ -350,6 +357,10 @@#define IFA_F_SECONDARY 0x01#define IFA_F_TEMPORARY IFA_F_SECONDARY +#define IFA_F_ADDRESS 0x02 +#define IFA_F_MULTICAST 0x04 +#define IFA_F_ANYCAST 0x08 +#define IFA_F_DEPRECATED 0x20#define IFA_F_TENTATIVE 0x40#define IFA_F_PERMANENT 0x80
net/ipv6/addrconf.c +71 -23
132 lines not on this page · raw message
Quoted 2 lines · On Wed, 17 Mar 2004 11:30:30 -0800 Shirley Ma <[email protected]> wrote:
This patch is against Linux 2.6.4 kernel. It has been tested, 'ip' utility works fine. This patch is used by IPv6 MIBs.
Are we really going to support adding anycast/multicast addresses using RTM_NEW{MULTI,ANY}CAST rtmsgs? If not, let's not add them.
Otherwise I like your patch.
In article <[email protected]> (at Thu, 18 Mar 2004 22:06:47 -0800), "David S. Miller" <[email protected]> says:
Quoted 10 lines
Quoted 2 lines · On Wed, 17 Mar 2004 11:30:30 -0800 Shirley Ma <[email protected]> wrote:
This patch is against Linux 2.6.4 kernel. It has been tested, 'ip' utility works fine. This patch is used by IPv6 MIBs.
Are we really going to support adding anycast/multicast addresses using RTM_NEW{MULTI,ANY}CAST rtmsgs? If not, let's not add them.
Otherwise I like your patch.
I think we'd like to do so (for anycast at least).
Signature · 2 lines
Hideaki YOSHIFUJI @ USAGI Project <[email protected]> GPG FP: 9022 65EB 1ECF 3AD1 0BDF 80D8 4807 F894 E062 0EEA
In article <[email protected]> (at Wed, 17 Mar 2004 11:30:30 -0800), Shirley Ma <[email protected]> says:
include/linux/rtnetlink.h line 351
Quoted 8 lines
include/linux/rtnetlink.h +1
-0@@ -339,6 +345,7 @@IFA_LOCAL ,IFA_LABEL ,IFA_BROADCAST , +IFA_MULTICAST ,IFA_ANYCAST , IFA_CACHEINFO };
Please, please do not change IFA_XXX values. You should put "IFA_MULTICAST" next to IFA_CACHEINFO.
--yoshfuji
Thanks for your comments.
I am going to modify the patch,
removing RTM_NEWMULTICAST replaced by RTM_GETMULTICAST, removing RTM_NEWANYCAST replaced by RTM_GETANYCAST. IFA_MULTICAST must be added last!
RTM_NEWANYCAST could be added later for adding anycast addresses through netlink as a seperate patch.
I will resubmit the patch after I come back from my vacation one week later.
Thanks
Shirley Ma
IBM Linux Technology Center
15300 SW Koll Parkway
Beaverton, OR 97006-6063
Phone: (503) 578-7638
FAX: (503) 578-3228
YOSHIFUJI Hideaki
/ 吉藤英明
<yoshfuji@linux-i To
pv6.org> [email protected]
Sent by: cc
netdev-bounce@oss [email protected],
.sgi.com [email protected], Shirley
Ma/Beaverton/IBM@IBMUS, [email protected]
03/18/2004 10:55 Subject
PM Re: [PATCH]dump interface IPv6
multicast/anycast addresses through netlink
In article <[email protected]> (at Wed, 17 Mar 2004 11:30:30 -0800), Shirley Ma <[email protected]> says:
include/linux/rtnetlink.h line 351
Quoted 8 lines
include/linux/rtnetlink.h +1
-0@@ -339,6 +345,7 @@IFA_LOCAL ,IFA_LABEL ,IFA_BROADCAST , +IFA_MULTICAST ,IFA_ANYCAST , IFA_CACHEINFO };
Please, please do not change IFA_XXX values. You should put "IFA_MULTICAST" next to IFA_CACHEINFO.
--yoshfuji
Quoted 3 lines · On Thu, 18 Mar 2004 23:16:52 -0800 Shirley Ma <[email protected]> wrote:
I am going to modify the patch,
removingRTM_NEWMULTICASTreplaced byRTM_GETMULTICAST, removingRTM_NEWANYCASTreplaced byRTM_GETANYCAST.
Please remember to number the RTM_* values correctly, the low order bits tell if the operation does a read or write operation.
Yes. I will.
Thanks
Shirley Ma
IBM Linux Technology Center
15300 SW Koll Parkway
Beaverton, OR 97006-6063
Phone: (503) 578-7638
FAX: (503) 578-3228
Here is the new patch. It has been tested against linux 2.6.4 kernel.
Thanks
Shirley Ma
IBM Linux Technology Center
include/linux/rtnetlink.h +11 -2
@@ -47,7 +47,11 @@#define RTM_NEWPREFIX (RTM_BASE+36)#define RTM_GETPREFIX (RTM_BASE+38) -#define RTM_MAX (RTM_BASE+39) +#define RTM_GETMULTICAST (RTM_BASE+42) + +#define RTM_GETANYCAST (RTM_BASE+46) + +#define RTM_MAX (RTM_BASE+47)/* Generic structure for encapsulation of optional route information.
@@ -340,7 +344,8 @@IFA_LABEL ,IFA_BROADCAST ,IFA_ANYCAST , - IFA_CACHEINFO +IFA_CACHEINFO , + IFA_MULTICAST };#define IFA_MAX IFA_CACHEINFO
@@ -350,6 +355,10 @@#define IFA_F_SECONDARY 0x01#define IFA_F_TEMPORARY IFA_F_SECONDARY +#define IFA_F_ADDRESS 0x02 +#define IFA_F_MULTICAST 0x04 +#define IFA_F_ANYCAST 0x08 +#define IFA_F_DEPRECATED 0x20#define IFA_F_TENTATIVE 0x40#define IFA_F_PERMANENT 0x80
net/ipv6/addrconf.c +71 -23
132 lines not on this page · raw message
Hello.
In article <[email protected]> (at Wed, 31 Mar 2004 10:07:01 -0800), Shirley Ma <[email protected]> says:
include/linux/rtnetlink.h line 364
Quoted 11 lines
include/linux/rtnetlink.h +4
-0@@ -350,6 +355,10 @@#define IFA_F_SECONDARY 0x01#define IFA_F_TEMPORARY IFA_F_SECONDARY +#define IFA_F_ADDRESS 0x02 +#define IFA_F_MULTICAST 0x04 +#define IFA_F_ANYCAST 0x08 +#define IFA_F_DEPRECATED 0x20#define IFA_F_TENTATIVE 0x40#define IFA_F_PERMANENT 0x80
Why do we need IFA_F_MULTICAST?
This is waste of flags.
net/ipv6/addrconf.c line 2631
Quoted 3 lines
net/ipv6/addrconf.c +2
-1-static int inet6_dump_ifaddr (struct sk_buff *skb,struct netlink_callback *cb) +static int inet6_dump_addr (struct sk_buff *skb,struct netlink_callback *cb, +unsigned char flags)
unsigned char type)
net/ipv6/addrconf.c line 2655
Quoted 1 line
net/ipv6/addrconf.c +1
-0+if (flags &IFA_F_ADDRESS ) {
type == 0
Quoted 23 lines
net/ipv6/addrconf.c +13
-9+/* unicast address */ +for (ifa = idev->addr_list; ifa; + ifa = ifa->if_next, ip_idx++) { +if (ip_idx < s_ip_idx) +continue ; +if ((err =inet6_fill_ifaddr (skb, ifa, +NETLINK_CB (cb->skb).pid, + cb->nlh->nlmsg_seq,RTM_NEWADDR )) <=0 ) + goto done; + } +/* temp addr */ #ifdef CONFIG_IPV6_PRIVACY -for (ifa = idev->tempaddr_list; ifa; - ifa = ifa->tmp_next, ip_idx++) { -if (ip_idx < s_ip_idx) -continue ; -if ((err =inet6_fill_ifaddr (skb, ifa, -NETLINK_CB (cb->skb).pid, - cb->nlh->nlmsg_seq,RTM_NEWADDR )) <=0 ) - goto done; - } +for (ifa = idev->tempaddr_list; ifa; + ifa = ifa->tmp_next, ip_idx++) {
net/ipv6/addrconf.c line 2679
Quoted 10 lines
net/ipv6/addrconf.c +9
-0+if (ip_idx < s_ip_idx) +continue ; +if ((err =inet6_fill_ifaddr (skb, ifa, +NETLINK_CB (cb->skb).pid, + cb->nlh->nlmsg_seq,RTM_NEWADDR )) <=0 ) + goto done; + }#endif + } +if (flags &IFA_F_MULTICAST ) {
type == IFA_MULTICAST
net/ipv6/addrconf.c line 2691
Quoted 12 lines
net/ipv6/addrconf.c +12
-0+/* multicast address */ +for (ifmca = idev->mc_list; ifmca; + ifmca = ifmca->next, ip_idx++) { +if (ip_idx < s_ip_idx) +continue ; +if ((err =inet6_fill_ifmcaddr (skb, ifmca, +NETLINK_CB (cb->skb).pid, + cb->nlh->nlmsg_seq,RTM_GETMULTICAST )) <=0 ) + goto done; + } + } +if (flags &IFA_F_ANYCAST ) {
type == IFA_ANYCAST
Quoted 15 lines
net/ipv6/addrconf.c +11
-0+/* anycast address */ +for (ifaca = idev->ac_list; ifaca; + ifaca = ifaca->aca_next, ip_idx++) { +if (ip_idx < s_ip_idx) +continue ; +if ((err =inet6_fill_ifacaddr (skb, ifaca, +NETLINK_CB (cb->skb).pid, + cb->nlh->nlmsg_seq,RTM_GETANYCAST )) <=0 ) + goto done; + } + }read_unlock_bh (&idev->lock);in6_dev_put (idev); }
net/ipv6/addrconf.c line 2720
Quoted 7 lines
net/ipv6/addrconf.c +4
-0@@ -2687,6 +2714,25 @@return skb->len; } +static int inet6_dump_ifaddr (struct sk_buff *skb,struct netlink_callback *cb) +{ +unsigned char flag =IFA_F_ADDRESS ; +return inet6_dump_addr (skb, cb, flag);
0
net/ipv6/addrconf.c line 2726
Quoted 6 lines
net/ipv6/addrconf.c +6
-0+} + +static int inet6_dump_ifmcaddr (struct sk_buff *skb,struct netlink_callback *cb) +{ +unsigned char flag =IFA_F_MULTICAST ; +return inet6_dump_addr (skb, cb, flag);
IFA_MULTICAST
net/ipv6/addrconf.c line 2733
Quoted 7 lines
net/ipv6/addrconf.c +7
-0+} + + +static int inet6_dump_ifacaddr (struct sk_buff *skb,struct netlink_callback *cb) +{ +unsigned char flag =IFA_F_ANYCAST ; +return inet6_dump_addr (skb, cb, flag);
IFA_ANYCAST
net/ipv6/addrconf.c line 2738
Quoted 5 lines
net/ipv6/addrconf.c +2
-0+} +static void inet6_ifa_notify (int event,struct inet6_ifaddr *ifa) {struct sk_buff *skb;
Of course, we can use switch-case.
Signature · 2 lines
Hideaki YOSHIFUJI @ USAGI Project <[email protected]> GPG FP: 9022 65EB 1ECF 3AD1 0BDF 80D8 4807 F894 E062 0EEA
The reason to add these flags was for rtnetlink MATCH request through RTM_GETADDRESS. Since here we use RTM_GETMULTICAST, RTM_GETANYCAST for getting multicast/anycast addresses, it's not necessary to have these flags. I will remove them.
Thanks
Shirley Ma
IBM Linux Technology Center
15300 SW Koll Parkway
Beaverton, OR 97006-6063
Phone: (503) 578-7638
FAX: (503) 578-3228
Here is the new patch. It has been tested against linux 2.6.4 kernel.
Thanks
Shirley Ma
IBM Linux Technology Center
include/linux/rtnetlink.h +7 -2
@@ -47,7 +47,11 @@#define RTM_NEWPREFIX (RTM_BASE+36)#define RTM_GETPREFIX (RTM_BASE+38) -#define RTM_MAX (RTM_BASE+39) +#define RTM_GETMULTICAST (RTM_BASE+42) + +#define RTM_GETANYCAST (RTM_BASE+46) + +#define RTM_MAX (RTM_BASE+47)/* Generic structure for encapsulation of optional route information.
@@ -340,7 +344,8 @@IFA_LABEL ,IFA_BROADCAST ,IFA_ANYCAST , - IFA_CACHEINFO +IFA_CACHEINFO , + IFA_MULTICAST };#define IFA_MAX IFA_CACHEINFO
net/ipv6/addrconf.c +81 -23
142 lines not on this page · raw message
Quoted 1 line · On Thu, 1 Apr 2004 10:28:12 -0800 Shirley Ma <[email protected]> wrote:
Here is the new patch. It has been tested against linux 2.6.4 kernel.
I'm Ok with this patch and I believe Yoshfuji et al. are too.
But this patch will not apply cleanly to current 2.6.x sources, please rediff.
Thanks.
Dumping multicast/anycast api was removed in Linux 2.6.5 kernel, so it couldn't be applied cleanly.
I recreated the patch. This patch has been tested against linux-2.6.5 kernel.
include/linux/rtnetlink.h +7 -2
@@ -47,7 +47,11 @@#define RTM_NEWPREFIX (RTM_BASE+36)#define RTM_GETPREFIX (RTM_BASE+38) -#define RTM_MAX (RTM_BASE+39) +#define RTM_GETMULTICAST (RTM_BASE+42) + +#define RTM_GETANYCAST (RTM_BASE+46) + +#define RTM_MAX (RTM_BASE+47)/* Generic structure for encapsulation of optional route information.
@@ -340,7 +344,8 @@IFA_LABEL ,IFA_BROADCAST ,IFA_ANYCAST , - IFA_CACHEINFO +IFA_CACHEINFO , + IFA_MULTICAST };#define IFA_MAX IFA_CACHEINFO
net/ipv6/addrconf.c +157 -22
211 lines not on this page · raw message
David S. Miller
AppliedQuoted 3 lines · On Mon, 5 Apr 2004 13:51:09 -0700 Shirley Ma <[email protected]> wrote:
Dumping multicast/anycast api was removed in Linux 2.6.5 kernel, so it couldn't be applied cleanly.
I recreated the patch. This patch has been tested against linux-2.6.5 kernel.
Applied, thank you.
Fix IPv6 MIBs counters in 2.6.5 kernel
I have fixed IPv6 MIBs counters which don't increase under some cases
in linux-2.6.5 kernel.
Please review it.
Signature · 3 lines
Thanks Shirley Ma IBM Linux Technology Center
net/ipv6/exthdrs.c +15 -1
@@ -159,6 +159,7 @@if (!pskb_may_pull (skb, (skb->h.raw-skb->data)+8 ) || !pskb_may_pull (skb, (skb->h.raw-skb->data)+((skb->h.raw[1 ]+1 )<<3 ))) { +IP6_INC_STATS_BH (Ip6InHdrErrors);kfree_skb (skb);return -1 ; }
@@ -171,6 +172,7 @@return 1 ; } +IP6_INC_STATS_BH (Ip6InHdrErrors);return -1 ; }
@@ -234,6 +236,7 @@if (ipv6_addr_is_multicast (&skb->nh.ipv6h->daddr) || skb->pkt_type !=PACKET_HOST ) { +IP6_INC_STATS_BH (Ip6InAddrErrors);kfree_skb (skb);return -1 ; }
@@ -249,11 +252,13 @@ }if (hdr->type !=IPV6_SRCRT_TYPE_0 ) { +IP6_INC_STATS_BH (Ip6InHdrErrors);icmpv6_param_prob (skb,ICMPV6_HDR_FIELD , (&hdr->type) - skb->nh.raw);return -1 ; }if (hdr->hdrlen &0x01 ) { +IP6_INC_STATS_BH (Ip6InHdrErrors);icmpv6_param_prob (skb,ICMPV6_HDR_FIELD , (&hdr->hdrlen) - skb->nh.raw);return -1 ; }
@@ -266,6 +271,7 @@ n = hdr->hdrlen >>1 ;if (hdr->segments_left > n) { +IP6_INC_STATS_BH (Ip6InHdrErrors);icmpv6_param_prob (skb,ICMPV6_HDR_FIELD , (&hdr->segments_left) - skb->nh.raw);return -1 ; }
@@ -276,8 +282,11 @@if (skb_cloned (skb)) {struct sk_buff *skb2 =skb_copy (skb,GFP_ATOMIC );kfree_skb (skb); -if (skb2 ==NULL ) +/* the copy is a forwarded packet */ +if (skb2 ==NULL ) { +IP6_INC_STATS_BH (Ip6OutDiscards);return -1 ; + } *skbp = skb = skb2; opt = (struct inet6_skb_parm *)skb2->cb; hdr = (struct ipv6_rt_hdr *) skb2->h.raw;
@@ -293,6 +302,7 @@ addr += i -1 ;if (ipv6_addr_is_multicast (addr)) { +IP6_INC_STATS_BH (Ip6InAddrErrors);kfree_skb (skb);return -1 ; }
@@ -309,6 +319,7 @@ }if (skb->dst->dev->flags&IFF_LOOPBACK ) {if (skb->nh.ipv6h->hop_limit <=1 ) { +IP6_INC_STATS_BH (Ip6InHdrErrors);icmpv6_send (skb,ICMPV6_TIME_EXCEED ,ICMPV6_EXC_HOPLIMIT ,0 , skb->dev);kfree_skb (skb);
@@ -425,15 +436,18 @@if (skb->nh.raw[optoff+1 ] !=4 || (optoff&3 ) !=2 ) {if (net_ratelimit ())printk (KERN_DEBUG "ipv6_hop_jumbo: wrong jumbo opt length/alignment %d\n" , skb->nh.raw[optoff+1 ]); +IP6_INC_STATS_BH (Ip6InHdrErrors); goto drop; } pkt_len =ntohl (*(u32 *)(skb->nh.raw+optoff+2 ));if (pkt_len <=IPV6_MAXPLEN ) { +IP6_INC_STATS_BH (Ip6InHdrErrors);icmpv6_param_prob (skb,ICMPV6_HDR_FIELD , optoff+2 );return 0 ; }if (skb->nh.ipv6h->payload_len) { +IP6_INC_STATS_BH (Ip6InHdrErrors);icmpv6_param_prob (skb,ICMPV6_HDR_FIELD , optoff);return 0 ; }
net/ipv6/ip6_input.c +7 -2
@@ -79,8 +79,10 @@if (skb->len <sizeof (struct ipv6hdr )) goto err; -if (!pskb_may_pull (skb,sizeof (struct ipv6hdr ))) +if (!pskb_may_pull (skb,sizeof (struct ipv6hdr ))) { +IP6_INC_STATS_BH (Ip6InHdrErrors); goto drop; + } hdr = skb->nh.ipv6h;
@@ -94,8 +96,10 @@if (pkt_len +sizeof (struct ipv6hdr ) > skb->len) goto truncated;if (pkt_len +sizeof (struct ipv6hdr ) < skb->len) { -if (__pskb_trim (skb, pkt_len +sizeof (struct ipv6hdr ))) +if (__pskb_trim (skb, pkt_len +sizeof (struct ipv6hdr ))){ +IP6_INC_STATS_BH (Ip6InHdrErrors); goto drop; + } hdr = skb->nh.ipv6h;if (skb->ip_summed ==CHECKSUM_HW ) skb->ip_summed =CHECKSUM_NONE ;
@@ -206,6 +210,7 @@return 0 ; discard: +IP6_INC_STATS_BH (Ip6InDiscards);rcu_read_unlock ();kfree_skb (skb);return 0 ;
net/ipv6/ip6_output.c +22 -5
@@ -87,6 +87,7 @@ }else if (dst->neighbour)return dst->neighbour->output (skb); +IP6_INC_STATS_BH (Ip6OutNoRoutes);kfree_skb (skb);return -EINVAL ;
@@ -131,6 +132,7 @@ ip6_dev_loopback_xmit);if (skb->nh.ipv6h->hop_limit ==0 ) { +IP6_INC_STATS (Ip6OutDiscards);kfree_skb (skb);return 0 ; }
@@ -167,6 +169,7 @@ dst =ip6_route_output (skb->sk, &fl);if (dst->error) { +IP6_INC_STATS (Ip6OutNoRoutes);if (net_ratelimit ())printk (KERN_DEBUG "ip6_route_me_harder: No more route.\n" );dst_release (dst);
@@ -224,8 +227,10 @@struct sk_buff *skb2 =skb_realloc_headroom (skb, head_room);kfree_skb (skb); skb = skb2; -if (skb ==NULL ) +if (skb ==NULL ) { +IP6_INC_STATS (Ip6OutDiscards);return -ENOBUFS ; + }if (sk)skb_set_owner_w (skb, sk); }
@@ -265,6 +270,7 @@printk (KERN_DEBUG "IPv6: sending pkt_too_big to self\n" ); skb->dev = dst->dev;icmpv6_send (skb,ICMPV6_PKT_TOOBIG ,0 , mtu, skb->dev); +IP6_INC_STATS (Ip6FragFails);kfree_skb (skb);return -EMSGSIZE ; }
@@ -345,8 +351,10 @@if (ipv6_devconf.forwarding ==0 ) goto error; -if (!xfrm6_policy_check (NULL ,XFRM_POLICY_FWD , skb)) +if (!xfrm6_policy_check (NULL ,XFRM_POLICY_FWD , skb)) { +IP6_INC_STATS (Ip6InDiscards); goto drop; + } skb->ip_summed =CHECKSUM_NONE ;
@@ -382,8 +390,10 @@return -ETIMEDOUT ; } -if (!xfrm6_route_forward (skb)) +if (!xfrm6_route_forward (skb)) { +IP6_INC_STATS (Ip6InDiscards); goto drop; + }/* IPv6 specs say nothing about it, but it is clear that we cannot send redirects to source routed frames.
@@ -420,12 +430,15 @@ skb->dev = dst->dev;icmpv6_send (skb,ICMPV6_PKT_TOOBIG ,0 ,dst_pmtu (dst), skb->dev);IP6_INC_STATS_BH (Ip6InTooBigErrors); +IP6_INC_STATS_BH (Ip6FragFails);kfree_skb (skb);return -EMSGSIZE ; } -if (skb_cow (skb, dst->dev->hard_header_len)) +if (skb_cow (skb, dst->dev->hard_header_len)) { +IP6_INC_STATS (Ip6OutDiscards); goto drop; + } hdr = skb->nh.ipv6h;
@@ -648,6 +661,7 @@if ((frag =alloc_skb (len+hlen+sizeof (struct frag_hdr )+LL_RESERVED_SPACE (rt->u.dst.dev),GFP_ATOMIC )) ==NULL ) {NETDEBUG (printk (KERN_INFO "IPv6: frag: no memory for new fragment!\n" )); +IP6_INC_STATS (Ip6FragFails); err = -ENOMEM ; goto fail; }
@@ -1062,6 +1076,7 @@ipv6_addr_copy (&hdr->daddr, final_dst); skb->dst =dst_clone (&rt->u.dst); +IP6_INC_STATS (Ip6OutRequests); err =NF_HOOK (PF_INET6 ,NF_IP6_LOCAL_OUT , skb,NULL , skb->dst->dev, dst_output);if (err) {if (err >0 )
@@ -1092,8 +1107,10 @@struct ipv6_pinfo *np =inet6_sk (sk);struct sk_buff *skb; -while ((skb =__skb_dequeue_tail (&sk->sk_write_queue)) !=NULL ) +while ((skb =__skb_dequeue_tail (&sk->sk_write_queue)) !=NULL ) { +IP6_INC_STATS (Ip6OutDiscards);kfree_skb (skb); + } inet->cork.flags &= ~IPCORK_OPT ;
net/ipv6/ndisc.c +4 -0
@@ -452,6 +452,7 @@ skb->dst = dst; idev =in6_dev_get (dst->dev); +IP6_INC_STATS (Ip6OutRequests); err =NF_HOOK (PF_INET6 ,NF_IP6_LOCAL_OUT , skb,NULL , dst->dev, dst_output);if (!err) {ICMP6_INC_STATS (idev, Icmp6OutNeighborAdvertisements);
@@ -535,6 +536,7 @@/* send it! */ skb->dst = dst; idev =in6_dev_get (dst->dev); +IP6_INC_STATS (Ip6OutRequests); err =NF_HOOK (PF_INET6 ,NF_IP6_LOCAL_OUT , skb,NULL , dst->dev, dst_output);if (!err) {ICMP6_INC_STATS (idev, Icmp6OutNeighborSolicits);
@@ -607,6 +609,7 @@/* send it! */ skb->dst = dst; idev =in6_dev_get (dst->dev); +IP6_INC_STATS (Ip6OutRequests); err =NF_HOOK (PF_INET6 ,NF_IP6_LOCAL_OUT , skb,NULL , dst->dev, dst_output);if (!err) {ICMP6_INC_STATS (idev, Icmp6OutRouterSolicits);
@@ -1332,6 +1335,7 @@ buff->dst = dst; idev =in6_dev_get (dst->dev); +IP6_INC_STATS (Ip6OutRequests); err =NF_HOOK (PF_INET6 ,NF_IP6_LOCAL_OUT , buff,NULL , dst->dev, dst_output);if (!err) {ICMP6_INC_STATS (idev, Icmp6OutRedirects);
net/ipv6/raw.c +1 -0
@@ -526,6 +526,7 @@if (err) goto error_fault; +IP6_INC_STATS (Ip6OutRequests); err =NF_HOOK (PF_INET6 ,NF_IP6_LOCAL_OUT , skb,NULL , rt->u.dst.dev, dst_output);if (err >0 )
net/ipv6/reassembly.c +5 -0
@@ -426,6 +426,7 @@ ((u8 *) (fhdr + 1) - (u8 *) (skb->nh.ipv6h + 1)));if ((unsigned int )end >IPV6_MAXPLEN ) { +IP6_INC_STATS_BH (Ip6InHdrErrors);icmpv6_param_prob (skb,ICMPV6_HDR_FIELD , (u8 *)&fhdr->frag_off - skb->nh.raw);return ; }
@@ -452,6 +453,7 @@/* RFC2460 says always send parameter problem in * this case. -DaveM */ +IP6_INC_STATS_BH (Ip6InHdrErrors);icmpv6_param_prob (skb,ICMPV6_HDR_FIELD , offsetof(struct ipv6hdr , payload_len));return ;
@@ -570,6 +572,7 @@return ; err: +IP6_INC_STATS (Ip6ReasmFails);kfree_skb (skb); }
@@ -694,10 +697,12 @@/* Jumbo payload inhibits frag. header */ if (hdr->payload_len==0 ) { +IP6_INC_STATS (Ip6InHdrErrors);icmpv6_param_prob (skb,ICMPV6_HDR_FIELD , skb->h.raw-skb->nh.raw);return -1 ; }if (!pskb_may_pull (skb, (skb->h.raw-skb->data)+sizeof (struct frag_hdr ))) { +IP6_INC_STATS (Ip6InHdrErrors);icmpv6_param_prob (skb,ICMPV6_HDR_FIELD , skb->h.raw-skb->nh.raw);return -1 ; }
Re: Fix IPv6 MIBs counters in 2.6.5 kernel
Looks great Shirley, patch applied.
Thanks.
PATCH 1/1 Add IPv6 MIBs counters in MLD (mcast.c)
In reply to Shirley MaHere is the patch against linux 2.6.4 kernel. Please review it.
Thanks
Shirley Ma
IBM Linux Technology Center
net/ipv6/mcast.c +14 -3
@@ -1317,6 +1317,7 @@struct inet6_dev *idev =in6_dev_get (skb->dev);int err; +IP6_INC_STATS (Ip6OutRequests); payload_len = skb->tail - (unsigned char *)skb->nh.ipv6h -sizeof (struct ipv6hdr ); mldlen = skb->tail - skb->h.raw;
@@ -1326,8 +1327,12 @@ IPPROTO_ICMPV6, csum_partial(skb->h.raw, mldlen, 0)); err =NF_HOOK (PF_INET6 ,NF_IP6_LOCAL_OUT , skb,NULL , skb->dev, dev_queue_xmit); -if (!err) +if (!err) {ICMP6_INC_STATS (idev,Icmp6OutMsgs); +IP6_INC_STATS (Ip6OutMcastPkts); + }else +IP6_INC_STATS (Ip6OutDiscards); +if (likely (idev !=NULL ))in6_dev_put (idev); }
@@ -1608,6 +1613,7 @@IPV6_TLV_ROUTERALERT ,2 ,0 ,0 , IPV6_TLV_PADN, 0 }; +IP6_INC_STATS (Ip6OutRequests); snd_addr = addr;if (type ==ICMPV6_MGM_REDUCTION ) { snd_addr = &all_routers;
@@ -1620,8 +1626,10 @@ skb =sock_alloc_send_skb (sk,LL_RESERVED_SPACE (dev) + full_len,1 , &err); -if (skb ==NULL ) +if (skb ==NULL ) { +IP6_INC_STATS (Ip6OutDiscards);return ; + }skb_reserve (skb,LL_RESERVED_SPACE (dev));if (dev->hard_header) {
@@ -1664,13 +1672,16 @@else ICMP6_INC_STATS (idev, Icmp6OutGroupMembResponses);ICMP6_INC_STATS (idev, Icmp6OutMsgs); - } +IP6_INC_STATS (Ip6OutMcastPkts); + }else +IP6_INC_STATS (Ip6OutDiscards);if (likely (idev !=NULL ))in6_dev_put (idev);return ; out: +IP6_INC_STATS (Ip6OutDiscards);kfree_skb (skb); }
Re: [PATCH]Add IPv6 MIBs counters in MLD (mcast.c)
Quoted 1 line · On Wed, 31 Mar 2004 13:26:43 -0800 Shirley Ma <[email protected]> wrote:
Here is the patch against linux 2.6.4 kernel. Please review it.
Patch applied, thanks Shirley.
PATCH 1/1 Add new IPv6 MIBs counters support through netlink
In reply to Shirley MaThis patch implements both per interface and global new IPv6 MIBs counters through netlink based on new IP MIBs draft, 64 bit counters are not supported here because of performance issues. It coexists old IPv6 MIBs counters (which are through proc file system) for the compatibility.
This patch is against 2.6.6 kernel. It has been tested for IPv6. Please review it.
include/linux/rtnetlink.h +20 -0
@@ -44,6 +44,9 @@#define RTM_DELTFILTER (RTM_BASE+29)#define RTM_GETTFILTER (RTM_BASE+30) +#define RTM_NEWIPSTATS (RTM_BASE+32) +#define RTM_GETIPSTATS (RTM_BASE+34) +#define RTM_NEWPREFIX (RTM_BASE+36)#define RTM_GETPREFIX (RTM_BASE+38)
@@ -637,6 +640,23 @@#define TCA_RTA (r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct tcmsg))))#define TCA_PAYLOAD (n) NLMSG_PAYLOAD(n,sizeof(struct tcmsg)) +/******************************************************************** +* IP mibs information +****/ +struct ipstatsmsg +{ +int ipstats_family; +int ipstats_ifindex; +}; + +enum +{ +IPSTATS_IFNAME , +IPSTATS_COUNTERS , +}; + +#define IPSTATS_MAX IPSTATS_COUNTERS +/* SUMMARY: maximal rtattr understood by kernel */
include/net/if_inet6.h +1 -0
@@ -149,6 +149,7 @@struct ipv6_devstat {struct proc_dir_entry *proc_dir_entry; DEFINE_SNMP_STAT(struct icmpv6_mib, icmpv6); + DEFINE_SNMP_STAT(struct ip_stats, ipv6); };struct inet6_dev
include/net/ipv6.h +38 -0
@@ -116,6 +116,44 @@#define IP6_INC_STATS_BH (field) SNMP_INC_STATS_BH(ipv6_statistics, field)#define IP6_INC_STATS_USER (field) SNMP_INC_STATS_USER(ipv6_statistics, field) DECLARE_SNMP_STAT(struct icmpv6_mib, icmpv6_statistics); +/* new IPv6 MIB */ +DECLARE_SNMP_STAT(struct ip_stats, ipv6_stats); +#define IPV6_INC_STATS (idev, field) ({ \ + struct inet6_dev *_idev = (idev); \ + if (likely(_idev != NULL)) \ + SNMP_INC_STATS(_idev->stats.ipv6, field); \ + SNMP_INC_STATS(ipv6_stats, field); \ +}) +#define IPV6_INC_STATS_BH (idev, field) ({ \ + struct inet6_dev *_idev = (idev); \ + if (likely(_idev != NULL)) \ + SNMP_INC_STATS(_idev->stats.ipv6, field); \ + SNMP_INC_STATS_BH(ipv6_stats, field); \ +}) +#define IPV6_INC_STATS_USER (idev, field) ({ \ + struct inet6_dev *_idev = (idev); \ + if (likely(_idev != NULL)) \ + SNMP_INC_STATS(_idev->stats.ipv6, field); \ + SNMP_INC_STATS_USER(ipv6_stats, field); \ +}) +#define IPV6_ADD_STATS_BH (idev, field, addend) ({ \ + struct inet6_dev *_idev = (idev); \ + if (likely(_idev != NULL)) \ + SNMP_ADD_STATS_BH(_idev->stats.ipv6, field, addend); \ + SNMP_ADD_STATS_BH(ipv6_stats, field, addend); \ +}) +#define IPV6_ADD_STATS_USER (idev, field, addend) ({ \ + struct inet6_dev *_idev = (idev); \ + if (likely(_idev != NULL)) \ + SNMP_ADD_STATS_USER(_idev->stats.ipv6, field, addend); \ + SNMP_ADD_STATS_USER(ipv6_stats, field, addend); \ +}) +#define IPV6_ADD_STATS (idev, field, addend) ({ \ + struct inet6_dev *_idev = (idev); \ + if (likely(_idev != NULL)) \ + SNMP_ADD_STATS(_idev->stats.ipv6, field, addend); \ + SNMP_ADD_STATS(ipv6_stats, field, addend); \ +})#define ICMP6_INC_STATS (idev, field) ({ \ struct inet6_dev *_idev = (idev); \ if (likely(_idev != NULL)) \
include/net/snmp.h +39 -0
@@ -98,6 +98,43 @@unsigned long Ip6OutMcastPkts;unsigned long __pad[0 ]; }; + +/* +* New IP MIBs from draft-ietf-ipv6-rfc2011-update-05.txt +*/ +struct ip_stats +{ +unsigned long ipStatsInReceives; +unsigned long ipStatsInOctets; +unsigned long ipStatsInHdrErrors; +unsigned long ipStatsInNoRoutes; +unsigned long ipStatsInAddrErrors; +unsigned long ipStatsInUnknownProtos; +unsigned long ipStatsInTruncatedPkts; +unsigned long ipStatsInForwDatagrams; +unsigned long ipStatsReasmReqds; +unsigned long ipStatsReasmOKs; +unsigned long ipStatsReasmFails; +unsigned long ipStatsInDiscards; +unsigned long ipStatsInDelivers; +unsigned long ipStatsOutRequests; +unsigned long ipStatsOutNoRoutes; +unsigned long ipStatsOutForwDatagrams; +unsigned long ipStatsOutDiscards; +unsigned long ipStatsOutFragReqds; +unsigned long ipStatsOutFragOKs; +unsigned long ipStatsOutFragFails; +unsigned long ipStatsOutFragCreates; +unsigned long ipStatsOutTransmits; +unsigned long ipStatsOutOctets; +unsigned long ipStatsInMcastPkts; +unsigned long ipStatsInMcastOctets; +unsigned long ipStatsOutMcastPkts; +unsigned long ipStatsOutMcastOctets; +unsigned long ipStatsInBcastPkts; +unsigned long ipStatsOutBcastPkts; +unsigned long __pad[0 ]; +};/* * RFC 1213: MIB-II ICMP Group
@@ -335,6 +372,8 @@ (per_cpu_ptr(mib[!in_softirq()], smp_processor_id())->field++)#define SNMP_DEC_STATS (mib, field) \ (per_cpu_ptr(mib[!in_softirq()], smp_processor_id())->field--) +#define SNMP_ADD_STATS (mib, field, addend) \ + (per_cpu_ptr(mib[!in_softirq()], smp_processor_id())->field += addend)#define SNMP_ADD_STATS_BH (mib, field, addend) \ (per_cpu_ptr(mib[0], smp_processor_id())->field += addend)#define SNMP_ADD_STATS_USER (mib, field, addend) \
net/ipv6/addrconf.c +96 -0
108 lines not on this page · raw message
net/ipv6/af_inet6.c +6 -0
@@ -670,6 +670,9 @@if (snmp6_mib_init ((void **)ipv6_statistics,sizeof (struct ipv6_mib ), __alignof__(struct ipv6_mib )) <0 ) goto err_ip_mib; +if (snmp6_mib_init ((void **)ipv6_stats,sizeof (struct ip_stats ), + __alignof__(struct ip_stats )) <0 ) + goto err_ip6_mib;if (snmp6_mib_init ((void **)icmpv6_statistics,sizeof (struct icmpv6_mib ), __alignof__(struct ipv6_mib )) <0 ) goto err_icmp_mib;
@@ -681,6 +684,8 @@ err_udp_mib:snmp6_mib_free ((void **)icmpv6_statistics); err_icmp_mib: +snmp6_mib_free ((void **)ipv6_stats); +err_ip6_mib:snmp6_mib_free ((void **)ipv6_statistics); err_ip_mib:return -ENOMEM ;
@@ -690,6 +695,7 @@static void cleanup_ipv6_mibs (void ) {snmp6_mib_free ((void **)ipv6_statistics); +snmp6_mib_free ((void **)ipv6_stats);snmp6_mib_free ((void **)icmpv6_statistics);snmp6_mib_free ((void **)udp_stats_in6); }
net/ipv6/exthdrs.c +27 -1
@@ -156,10 +156,15 @@ {struct sk_buff *skb = *skbp;struct inet6_skb_parm *opt = (struct inet6_skb_parm *)skb->cb; +struct inet6_dev *idev =NULL ; + +if (likely (skb->dev)) + idev =__in6_dev_get (skb->dev);if (!pskb_may_pull (skb, (skb->h.raw-skb->data)+8 ) || !pskb_may_pull (skb, (skb->h.raw-skb->data)+((skb->h.raw[1 ]+1 )<<3 ))) {IP6_INC_STATS_BH (Ip6InHdrErrors); +IPV6_INC_STATS_BH (idev, ipStatsInHdrErrors);kfree_skb (skb);return -1 ; }
@@ -173,6 +178,7 @@ }IP6_INC_STATS_BH (Ip6InHdrErrors); +IPV6_INC_STATS_BH (idev, ipStatsInHdrErrors);return -1 ; }
@@ -224,10 +230,15 @@struct ipv6_rt_hdr *hdr;struct rt0_hdr *rthdr; +struct inet6_dev *idev =NULL ; + +if (likely (skb->dev)) + idev =__in6_dev_get (skb->dev);if (!pskb_may_pull (skb, (skb->h.raw-skb->data)+8 ) || !pskb_may_pull (skb, (skb->h.raw-skb->data)+((skb->h.raw[1 ]+1 )<<3 ))) {IP6_INC_STATS_BH (Ip6InHdrErrors); +IPV6_INC_STATS_BH (idev, ipStatsInHdrErrors);kfree_skb (skb);return -1 ; }
@@ -237,6 +248,7 @@if (ipv6_addr_is_multicast (&skb->nh.ipv6h->daddr) || skb->pkt_type !=PACKET_HOST ) {IP6_INC_STATS_BH (Ip6InAddrErrors); +IPV6_INC_STATS_BH (idev, ipStatsInAddrErrors);kfree_skb (skb);return -1 ; }
@@ -253,12 +265,14 @@if (hdr->type !=IPV6_SRCRT_TYPE_0 ) {IP6_INC_STATS_BH (Ip6InHdrErrors); +IPV6_INC_STATS_BH (idev, ipStatsInHdrErrors);icmpv6_param_prob (skb,ICMPV6_HDR_FIELD , (&hdr->type) - skb->nh.raw);return -1 ; }if (hdr->hdrlen &0x01 ) {IP6_INC_STATS_BH (Ip6InHdrErrors); +IPV6_INC_STATS_BH (idev, ipStatsInHdrErrors);icmpv6_param_prob (skb,ICMPV6_HDR_FIELD , (&hdr->hdrlen) - skb->nh.raw);return -1 ; }
@@ -272,6 +286,7 @@if (hdr->segments_left > n) {IP6_INC_STATS_BH (Ip6InHdrErrors); +IPV6_INC_STATS_BH (idev, ipStatsInHdrErrors);icmpv6_param_prob (skb,ICMPV6_HDR_FIELD , (&hdr->segments_left) - skb->nh.raw);return -1 ; }
@@ -284,7 +299,8 @@kfree_skb (skb);/* the copy is a forwarded packet */ if (skb2 ==NULL ) { -IP6_INC_STATS_BH (Ip6OutDiscards); +IP6_INC_STATS_BH (Ip6OutDiscards); +IPV6_INC_STATS_BH (idev, ipStatsOutDiscards);return -1 ; } *skbp = skb = skb2;
@@ -303,6 +319,7 @@if (ipv6_addr_is_multicast (addr)) {IP6_INC_STATS_BH (Ip6InAddrErrors); +IPV6_INC_STATS_BH (idev, ipStatsInAddrErrors);kfree_skb (skb);return -1 ; }
@@ -320,6 +337,7 @@if (skb->dst->dev->flags&IFF_LOOPBACK ) {if (skb->nh.ipv6h->hop_limit <=1 ) {IP6_INC_STATS_BH (Ip6InHdrErrors); +IPV6_INC_STATS_BH (idev, ipStatsInHdrErrors);icmpv6_send (skb,ICMPV6_TIME_EXCEED ,ICMPV6_EXC_HOPLIMIT ,0 , skb->dev);kfree_skb (skb);
@@ -432,28 +450,36 @@static int ipv6_hop_jumbo (struct sk_buff *skb,int optoff) {u32 pkt_len; +struct inet6_dev *idev =NULL ; + +if (likely (skb->dev)) + idev =__in6_dev_get (skb->dev);if (skb->nh.raw[optoff+1 ] !=4 || (optoff&3 ) !=2 ) {LIMIT_NETDEBUG (printk (KERN_DEBUG "ipv6_hop_jumbo: wrong jumbo opt length/alignment %d\n" , skb->nh.raw[optoff+1 ]));IP6_INC_STATS_BH (Ip6InHdrErrors); +IPV6_INC_STATS_BH (idev, ipStatsInHdrErrors); goto drop; } pkt_len =ntohl (*(u32 *)(skb->nh.raw+optoff+2 ));if (pkt_len <=IPV6_MAXPLEN ) {IP6_INC_STATS_BH (Ip6InHdrErrors); +IPV6_INC_STATS_BH (idev, ipStatsInHdrErrors);icmpv6_param_prob (skb,ICMPV6_HDR_FIELD , optoff+2 );return 0 ; }if (skb->nh.ipv6h->payload_len) {IP6_INC_STATS_BH (Ip6InHdrErrors); +IPV6_INC_STATS_BH (idev, ipStatsInHdrErrors);icmpv6_param_prob (skb,ICMPV6_HDR_FIELD , optoff);return 0 ; }if (pkt_len > skb->len -sizeof (struct ipv6hdr )) {IP6_INC_STATS_BH (Ip6InTruncatedPkts); +IPV6_INC_STATS_BH (idev, ipStatsInTruncatedPkts); goto drop; }if (pkt_len +sizeof (struct ipv6hdr ) < skb->len) {
net/ipv6/icmp.c +8 -0
@@ -158,6 +158,7 @@ {struct dst_entry *dst;int res =0 ; +struct inet6_dev *idev =NULL ;/* Informational messages are not limited. */ if (type &ICMPV6_INFOMSG_MASK )
@@ -173,8 +174,12 @@* this lookup should be more aggressive (not longer than timeout). */ dst =ip6_route_output (sk, fl); +/* idev reference for IP MIBs */ +if (likely (dst->dev)) + idev =in6_dev_get (dst->dev);if (dst->error) {IP6_INC_STATS (Ip6OutNoRoutes); +IPV6_INC_STATS (idev, ipStatsOutNoRoutes); }else if (dst->dev && (dst->dev->flags&IFF_LOOPBACK )) { res =1 ; }else {
@@ -187,6 +192,9 @@ res =xrlim_allow (dst, tmo); } +/* release the idev reference for IP MIBs */ +if (likely (idev)) +in6_dev_put (idev);dst_release (dst);return res; }
net/ipv6/ip6_input.c +35 -4
@@ -60,14 +60,22 @@ {struct ipv6hdr *hdr;u32 pkt_len; +struct inet6_dev *idev =NULL ; +int err =0 ; + +/* idev reference for input IP MIBs */ +if (likely (skb->dev)) + idev =in6_dev_get (skb->dev);if (skb->pkt_type ==PACKET_OTHERHOST ) goto drop;IP6_INC_STATS_BH (Ip6InReceives); +IPV6_INC_STATS_BH (idev, ipStatsInReceives);if ((skb =skb_share_check (skb,GFP_ATOMIC )) ==NULL ) {IP6_INC_STATS_BH (Ip6InDiscards); +IPV6_INC_STATS_BH (idev, ipStatsInDiscards); goto out; }
@@ -81,6 +89,7 @@if (!pskb_may_pull (skb,sizeof (struct ipv6hdr ))) {IP6_INC_STATS_BH (Ip6InHdrErrors); +IPV6_INC_STATS_BH (idev, ipStatsInHdrErrors); goto drop; }
@@ -90,6 +99,7 @@ goto err; pkt_len =ntohs (hdr->payload_len); +IPV6_ADD_STATS_BH (idev, ipStatsInOctets, skb->len);/* pkt_len may be zero if Jumbo payload option is present */ if (pkt_len || hdr->nexthdr !=NEXTHDR_HOP ) {
@@ -98,6 +108,7 @@if (pkt_len +sizeof (struct ipv6hdr ) < skb->len) {if (__pskb_trim (skb, pkt_len +sizeof (struct ipv6hdr ))){IP6_INC_STATS_BH (Ip6InHdrErrors); +IPV6_INC_STATS_BH (idev, ipStatsInHdrErrors); goto drop; } hdr = skb->nh.ipv6h;
@@ -110,20 +121,26 @@ skb->h.raw = (u8 *)(hdr+1 );if (ipv6_parse_hopopts (skb, offsetof(struct ipv6hdr , nexthdr)) <0 ) {IP6_INC_STATS_BH (Ip6InHdrErrors); -return 0 ; +IPV6_INC_STATS_BH (idev, ipStatsInHdrErrors); + goto out; } hdr = skb->nh.ipv6h; } -return NF_HOOK (PF_INET6 ,NF_IP6_PRE_ROUTING , skb, dev,NULL , ip6_rcv_finish); + err =NF_HOOK (PF_INET6 ,NF_IP6_PRE_ROUTING , skb, dev,NULL , ip6_rcv_finish); + goto out; truncated:IP6_INC_STATS_BH (Ip6InTruncatedPkts); +IPV6_INC_STATS_BH (idev, ipStatsInTruncatedPkts); err:IP6_INC_STATS_BH (Ip6InHdrErrors); +IPV6_INC_STATS_BH (idev, ipStatsInHdrErrors); drop:kfree_skb (skb); out: -return 0 ; +if (likely (idev)) +in6_dev_put (idev); +return err; }/*
@@ -139,6 +156,10 @@int nexthdr;u8 hash;int cksum_sub =0 ; +struct inet6_dev *idev =NULL ; + +if (skb->dev) + idev =__in6_dev_get (skb->dev); skb->h.raw = skb->nh.raw +sizeof (struct ipv6hdr );
@@ -193,16 +214,20 @@ ret = ipprot->handler (&skb, &nhoff);if (ret >0 ) goto resubmit; -else if (ret ==0 ) +else if (ret ==0 ) {IP6_INC_STATS_BH (Ip6InDelivers); +IPV6_INC_STATS_BH (idev, ipStatsInDelivers); + } }else {if (!raw_sk) {if (xfrm6_policy_check (NULL ,XFRM_POLICY_IN , skb)) {IP6_INC_STATS_BH (Ip6InUnknownProtos); +IPV6_INC_STATS_BH (idev, ipStatsInUnknownProtos);icmpv6_param_prob (skb,ICMPV6_UNK_NEXTHDR , nhoff); } }else {IP6_INC_STATS_BH (Ip6InDelivers); +IPV6_INC_STATS_BH (idev, ipStatsInDelivers);kfree_skb (skb); } }
@@ -211,6 +236,7 @@ discard:IP6_INC_STATS_BH (Ip6InDiscards); +IPV6_INC_STATS_BH (idev, ipStatsInDiscards);rcu_read_unlock ();kfree_skb (skb);return 0 ;
@@ -226,8 +252,13 @@ {struct ipv6hdr *hdr;int deliver; +struct inet6_dev *idev =NULL ; +if (skb->dev) + idev =__in6_dev_get (skb->dev);IP6_INC_STATS_BH (Ip6InMcastPkts); +IPV6_INC_STATS_BH (idev, ipStatsInMcastPkts); +IPV6_ADD_STATS_BH (idev, ipStatsInMcastOctets, skb->len); hdr = skb->nh.ipv6h; deliver = likely(!(skb->dev->flags & (IFF_PROMISC|IFF_ALLMULTI))) ||
net/ipv6/ip6_output.c +111 -15
357 lines not on this page · raw message
net/ipv6/ipv6_sockglue.c +1 -0
@@ -56,6 +56,7 @@#include <asm/uaccess.h> DEFINE_SNMP_STAT(struct ipv6_mib, ipv6_statistics); +DEFINE_SNMP_STAT(struct ip_stats, ipv6_stats);static struct packet_type ipv6_packet_type = { .type =__constant_htons (ETH_P_IPV6 ),
net/ipv6/mcast.c +22 -7
@@ -1318,6 +1318,8 @@int err;IP6_INC_STATS (Ip6OutRequests); +IPV6_INC_STATS (idev, ipStatsOutRequests); +IPV6_ADD_STATS (idev, ipStatsOutOctets, skb->len); payload_len = skb->tail - (unsigned char *)skb->nh.ipv6h -sizeof (struct ipv6hdr ); mldlen = skb->tail - skb->h.raw;
@@ -1330,10 +1332,13 @@if (!err) {ICMP6_INC_STATS (idev,Icmp6OutMsgs);IP6_INC_STATS (Ip6OutMcastPkts); - }else +IPV6_INC_STATS (idev, ipStatsOutMcastPkts); +IPV6_ADD_STATS (idev, ipStatsOutMcastOctets, skb->len); + }else {IP6_INC_STATS (Ip6OutDiscards); - -if (likely (idev !=NULL )) +IPV6_INC_STATS (idev, ipStatsOutDiscards); + } +if (idev)in6_dev_put (idev); }
@@ -1613,7 +1618,9 @@IPV6_TLV_ROUTERALERT ,2 ,0 ,0 , IPV6_TLV_PADN, 0 }; + idev =in6_dev_get (dev);IP6_INC_STATS (Ip6OutRequests); +IPV6_INC_STATS (idev, ipStatsOutRequests); snd_addr = addr;if (type ==ICMPV6_MGM_REDUCTION ) { snd_addr = &all_routers;
@@ -1628,9 +1635,13 @@if (skb ==NULL ) {IP6_INC_STATS (Ip6OutDiscards); +IPV6_INC_STATS (idev, ipStatsOutDiscards); +if (idev) +in6_dev_put (idev);return ; } +IPV6_ADD_STATS (idev, ipStatsOutOctets, skb->len);skb_reserve (skb,LL_RESERVED_SPACE (dev));if (dev->hard_header) {unsigned char ha[MAX_ADDR_LEN ];
@@ -1662,8 +1673,6 @@IPPROTO_ICMPV6 , csum_partial((__u8 *) hdr, len, 0)); - idev =in6_dev_get (skb->dev); - err =NF_HOOK (PF_INET6 ,NF_IP6_LOCAL_OUT , skb,NULL , skb->dev, dev_queue_xmit);if (!err) {
@@ -1673,16 +1682,22 @@ICMP6_INC_STATS (idev, Icmp6OutGroupMembResponses);ICMP6_INC_STATS (idev, Icmp6OutMsgs);IP6_INC_STATS (Ip6OutMcastPkts); - }else +IPV6_INC_STATS (idev, ipStatsOutMcastPkts); +IPV6_ADD_STATS (idev, ipStatsOutMcastOctets, skb->len); + }else {IP6_INC_STATS (Ip6OutDiscards); - +IPV6_INC_STATS (idev, ipStatsOutDiscards); + }if (likely (idev !=NULL ))in6_dev_put (idev);return ; out:IP6_INC_STATS (Ip6OutDiscards); +IPV6_INC_STATS (idev, ipStatsOutDiscards);kfree_skb (skb); +if (likely (idev !=NULL )) +in6_dev_put (idev); } static int ip6_mc_del1_src(struct ifmcaddr6 *pmc, int sfmode,
net/ipv6/ndisc.c +5 -1
@@ -453,6 +453,7 @@ skb->dst = dst; idev =in6_dev_get (dst->dev);IP6_INC_STATS (Ip6OutRequests); +IPV6_INC_STATS (idev, ipStatsOutRequests); err =NF_HOOK (PF_INET6 ,NF_IP6_LOCAL_OUT , skb,NULL , dst->dev, dst_output);if (!err) {ICMP6_INC_STATS (idev, Icmp6OutNeighborAdvertisements);
@@ -537,6 +538,7 @@ skb->dst = dst; idev =in6_dev_get (dst->dev);IP6_INC_STATS (Ip6OutRequests); +IPV6_INC_STATS (idev, ipStatsOutRequests); err =NF_HOOK (PF_INET6 ,NF_IP6_LOCAL_OUT , skb,NULL , dst->dev, dst_output);if (!err) {ICMP6_INC_STATS (idev, Icmp6OutNeighborSolicits);
@@ -609,7 +611,8 @@/* send it! */ skb->dst = dst; idev =in6_dev_get (dst->dev); -IP6_INC_STATS (Ip6OutRequests); +IP6_INC_STATS (Ip6OutRequests); +IPV6_INC_STATS (idev, ipStatsOutRequests); err =NF_HOOK (PF_INET6 ,NF_IP6_LOCAL_OUT , skb,NULL , dst->dev, dst_output);if (!err) {ICMP6_INC_STATS (idev, Icmp6OutRouterSolicits);
@@ -1336,6 +1339,7 @@ buff->dst = dst; idev =in6_dev_get (dst->dev);IP6_INC_STATS (Ip6OutRequests); +IPV6_INC_STATS (idev, ipStatsOutRequests); err =NF_HOOK (PF_INET6 ,NF_IP6_LOCAL_OUT , buff,NULL , dst->dev, dst_output);if (!err) {ICMP6_INC_STATS (idev, Icmp6OutRedirects);
net/ipv6/proc.c +13 -1
@@ -227,6 +227,9 @@if (snmp6_mib_init ((void **)idev->stats.icmpv6,sizeof (struct icmpv6_mib ), __alignof__(struct icmpv6_mib )) <0 ) goto err_icmp; +if (snmp6_mib_init ((void **)idev->stats.ipv6,sizeof (struct ip_stats ), + __alignof__(struct ip_stats )) <0 ) + goto err_ip;if (!proc_net_devsnmp6) { err = -ENOENT ;
@@ -242,8 +245,11 @@return 0 ; err_proc: +snmp6_mib_free ((void **)idev->stats.ipv6); +err_ip:snmp6_mib_free ((void **)idev->stats.icmpv6); err_icmp: +return err; }
@@ -256,6 +262,7 @@remove_proc_entry (idev->stats.proc_dir_entry->name, proc_net_devsnmp6);snmp6_mib_free ((void **)idev->stats.icmpv6); +snmp6_mib_free ((void **)idev->stats.ipv6);return 0 ; }
@@ -305,9 +312,13 @@if (snmp6_mib_init ((void **)idev->stats.icmpv6,sizeof (struct icmpv6_mib ), __alignof__(struct icmpv6_mib )) <0 ) goto err_icmp; +if (snmp6_mib_init ((void **)idev->stats.ipv6,sizeof (struct ip_stats ), + __alignof__(struct ip_stats )) <0 ) + goto err_ip;return 0 ; - +err_ip: +snmp6_mib_free ((void **)idev->stats.icmpv6); err_icmp:return err; }
@@ -315,6 +326,7 @@int snmp6_unregister_dev (struct inet6_dev *idev) {snmp6_mib_free ((void **)idev->stats.icmpv6); +snmp6_mib_free ((void **)idev->stats.ipv6);return 0 ; }
net/ipv6/raw.c +19 -6
@@ -498,11 +498,15 @@struct ipv6hdr *iph;struct sk_buff *skb;unsigned int hh_len; -int err; +int err =0 ; +struct inet6_dev *idev =NULL ; + +/* hold reference for IP MIBs */ if (length > rt->u.dst.dev->mtu) {ipv6_local_error (sk,EMSGSIZE , fl, rt->u.dst.dev->mtu); -return -EMSGSIZE ; + err = -EMSGSIZE ; + goto out; }if (flags&MSG_PROBE ) goto out;
@@ -518,6 +522,9 @@ skb->priority = sk->sk_priority; skb->dst =dst_clone (&rt->u.dst); +if (skb->dst) + idev =in6_dev_get (skb->dst->dev); + skb->nh.ipv6h = iph = (struct ipv6hdr *)skb_put (skb, length); skb->ip_summed =CHECKSUM_NONE ;
@@ -527,21 +534,27 @@if (err) goto error_fault; -IP6_INC_STATS (Ip6OutRequests); +IP6_INC_STATS (Ip6OutRequests); +IPV6_INC_STATS (idev, ipStatsOutRequests); +IPV6_ADD_STATS (idev, ipStatsOutOctets, skb->len); + err =NF_HOOK (PF_INET6 ,NF_IP6_LOCAL_OUT , skb,NULL , rt->u.dst.dev, dst_output);if (err >0 ) err = inet->recverr ?net_xmit_errno (err) :0 ;if (err) goto error; -out: -return 0 ; - +else + goto out; error_fault: err = -EFAULT ;kfree_skb (skb); error:IP6_INC_STATS (Ip6OutDiscards); +IPV6_INC_STATS (idev, ipStatsOutDiscards); +out: +if (idev) +in6_dev_put (idev);return err; } static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk,
net/ipv6/reassembly.c +36 -3
@@ -264,6 +264,7 @@ {struct frag_queue *fq;struct list_head *tmp; +struct inet6_dev *idev =NULL ;for (;;) {if (atomic_read (&ip6_frag_mem) <= sysctl_ip6frag_low_thresh)
@@ -285,12 +286,18 @@fq_put (fq);IP6_INC_STATS_BH (Ip6ReasmFails); +/* idev might be pointed to NULL */ +if (fq->fragments) + idev =__in6_dev_get (fq->fragments->dev); +IPV6_INC_STATS_BH (idev, ipStatsReasmFails); } }static void ip6_frag_expire (unsigned long data) {struct frag_queue *fq = (struct frag_queue *) data; +struct net_device *dev; +struct inet6_dev *idev =NULL ;spin_lock (&fq->lock);
@@ -301,10 +308,14 @@IP6_INC_STATS_BH (Ip6ReasmTimeout);IP6_INC_STATS_BH (Ip6ReasmFails); + dev =dev_get_by_index (fq->iif); +if (dev) + idev =__in6_dev_get (dev); +IPV6_INC_STATS_BH (idev, ipStatsInDiscards); +IPV6_INC_STATS_BH (idev, ipStatsReasmFails);/* Send error only if the first segment arrived. */ if (fq->last_in&FIRST_IN && fq->fragments) { -struct net_device *dev =dev_get_by_index (fq->iif);/* But use as source device on which LAST ARRIVED
@@ -315,9 +326,10 @@ fq->fragments->dev = dev;icmpv6_send (fq->fragments,ICMPV6_TIME_EXCEED ,ICMPV6_EXC_FRAGTIME ,0 , dev); -dev_put (dev); } } +if (dev) +dev_put (dev); out:spin_unlock (&fq->lock);fq_put (fq);
@@ -367,6 +379,7 @@ ip6_frag_create(unsigned int hash, u32 id, struct in6_addr *src, struct in6_addr *dst) { struct frag_queue *fq; +struct inet6_dev *idev =NULL ;if ((fq =frag_alloc_queue ()) ==NULL ) goto oom;
@@ -387,6 +400,7 @@ oom:IP6_INC_STATS_BH (Ip6ReasmFails); +IPV6_INC_STATS_BH (idev, ipStatsReasmFails);return NULL ; }
@@ -417,7 +431,10 @@ {struct sk_buff *prev, *next;int offset, end; +struct inet6_dev *idev =NULL ; +if (skb->dev) + idev =__in6_dev_get (skb->dev);if (fq->last_in &COMPLETE ) goto err;
@@ -427,6 +444,7 @@if ((unsigned int )end >IPV6_MAXPLEN ) {IP6_INC_STATS_BH (Ip6InHdrErrors); +IPV6_INC_STATS_BH (idev, ipStatsInHdrErrors);icmpv6_param_prob (skb,ICMPV6_HDR_FIELD , (u8 *)&fhdr->frag_off - skb->nh.raw);return ; }
@@ -454,6 +472,7 @@* this case. -DaveM */ IP6_INC_STATS_BH (Ip6InHdrErrors); +IPV6_INC_STATS_BH (idev, ipStatsInHdrErrors);icmpv6_param_prob (skb,ICMPV6_HDR_FIELD , offsetof(struct ipv6hdr , payload_len));return ;
@@ -573,6 +592,7 @@ err:IP6_INC_STATS (Ip6ReasmFails); +IPV6_INC_STATS_BH (idev, ipStatsReasmFails);kfree_skb (skb); }
@@ -592,7 +612,10 @@struct sk_buff *fp, *head = fq->fragments;int payload_len;unsigned int nhoff; - +struct inet6_dev *idev =NULL ; + +if (dev) + idev =__in6_dev_get (dev);fq_kill (fq);BUG_TRAP (head !=NULL );
@@ -667,6 +690,7 @@ head->csum =csum_partial (head->nh.raw, head->h.raw-head->nh.raw, head->csum);IP6_INC_STATS_BH (Ip6ReasmOKs); +IPV6_INC_STATS_BH (idev, ipStatsReasmOKs); fq->fragments =NULL ; *nhoffp = nhoff;return 1 ;
@@ -680,6 +704,7 @@printk (KERN_DEBUG "ip6_frag_reasm: no memory for reassembly\n" ); out_fail:IP6_INC_STATS_BH (Ip6ReasmFails); +IPV6_INC_STATS_BH (idev, ipStatsReasmFails);return -1 ; }
@@ -690,19 +715,25 @@struct frag_hdr *fhdr;struct frag_queue *fq;struct ipv6hdr *hdr; +struct inet6_dev *idev =NULL ; +if (dev) + idev =__in6_dev_get (dev); hdr = skb->nh.ipv6h;IP6_INC_STATS_BH (Ip6ReasmReqds); +IPV6_INC_STATS_BH (idev, ipStatsReasmReqds);/* Jumbo payload inhibits frag. header */ if (hdr->payload_len==0 ) {IP6_INC_STATS (Ip6InHdrErrors); +IPV6_INC_STATS_BH (idev, ipStatsInHdrErrors);icmpv6_param_prob (skb,ICMPV6_HDR_FIELD , skb->h.raw-skb->nh.raw);return -1 ; }if (!pskb_may_pull (skb, (skb->h.raw-skb->data)+sizeof (struct frag_hdr ))) {IP6_INC_STATS (Ip6InHdrErrors); +IPV6_INC_STATS_BH (idev, ipStatsInHdrErrors);icmpv6_param_prob (skb,ICMPV6_HDR_FIELD , skb->h.raw-skb->nh.raw);return -1 ; }
@@ -714,6 +745,7 @@/* It is not a fragmented frame */ skb->h.raw +=sizeof (struct frag_hdr );IP6_INC_STATS_BH (Ip6ReasmOKs); +IPV6_INC_STATS_BH (idev, ipStatsReasmOKs); *nhoffp = (u8 *)fhdr - skb->nh.raw;return 1 ;
@@ -739,6 +771,7 @@ }IP6_INC_STATS_BH (Ip6ReasmFails); +IPV6_INC_STATS_BH (idev, ipStatsReasmFails);kfree_skb (skb);return -1 ; }
net/ipv6/route.c +28 -6
@@ -85,7 +85,8 @@static struct dst_entry *ip6_negative_advice (struct dst_entry *);static int ip6_dst_gc (void ); -static int ip6_pkt_discard (struct sk_buff *skb); +static int ip6_pkt_indiscard (struct sk_buff *skb); +static int ip6_pkt_outdiscard (struct sk_buff *skb);static void ip6_link_failure (struct sk_buff *skb);static void ip6_rt_update_pmtu (struct dst_entry *dst,u32 mtu);
@@ -110,8 +111,8 @@ .obsolete = -1, .error = -ENETUNREACH, .metrics = { [RTAX_HOPLIMIT - 1] = 255, }, - .input = ip6_pkt_discard, - .output = ip6_pkt_discard, + .input = ip6_pkt_indiscard, + .output = ip6_pkt_outdiscard, .ops = &ip6_dst_ops, .path = (struct dst_entry*)&ip6_null_entry, }
@@ -767,8 +768,8 @@dev_put (dev); dev = &loopback_dev;dev_hold (dev); - rt->u.dst.output = ip6_pkt_discard; - rt->u.dst.input = ip6_pkt_discard; + rt->u.dst.output = ip6_pkt_outdiscard; + rt->u.dst.input = ip6_pkt_indiscard; rt->u.dst.error = -ENETUNREACH ; rt->rt6i_flags =RTF_REJECT |RTF_NONEXTHOP ; goto install_route;
@@ -1255,9 +1256,30 @@* Drop the packet on the floor */ -int ip6_pkt_discard (struct sk_buff *skb) +static int ip6_pkt_indiscard (struct sk_buff *skb) { +struct inet6_dev *idev =NULL ; + +if (skb->dev) + idev =__in6_dev_get (skb->dev); + +IP6_INC_STATS (Ip6InNoRoutes); +IPV6_INC_STATS (idev, ipStatsInNoRoutes); +icmpv6_send (skb,ICMPV6_DEST_UNREACH ,ICMPV6_NOROUTE ,0 , skb->dev); +kfree_skb (skb); +return 0 ; +} + + +static int ip6_pkt_outdiscard (struct sk_buff *skb) +{ +struct inet6_dev *idev =NULL ; + +if (skb->dev) + idev =__in6_dev_get (skb->dev); +IP6_INC_STATS (Ip6OutNoRoutes); +IPV6_INC_STATS (idev, ipStatsOutNoRoutes);icmpv6_send (skb,ICMPV6_DEST_UNREACH ,ICMPV6_NOROUTE ,0 , skb->dev);kfree_skb (skb);return 0 ;
Re: [PATCH]Add new IPv6 MIBs counters support through netlink
Quoted 4 lines · On Wed, 26 May 2004 13:10:05 -0700 Shirley Ma <[email protected]> wrote:
This patch implements both per interface and global new IPv6 MIBs counters through netlink based on new IP MIBs draft, 64 bit counters are not supported here because of performance issues. It coexists old IPv6 MIBs counters (which are through proc file system) for the compatibility.
Just to clarify, you named the struct ip_stats because we will use this eventually for ipv4 as well? Otherwise we should name it ip6_stats or something like that.
Otherwise I think your patch is fine.
Re: [PATCH]Add new IPv6 MIBs counters support through netlink
Yes, same structure ip_stats applys to IPv4 as well.
Thanks
Shirley Ma
IBM Linux Technology Center
15300 SW Koll Parkway
Beaverton, OR 97006-6063
Phone: (503) 578-7638
FAX: (503) 578-3228
Re: [PATCH]Add new IPv6 MIBs counters support through netlink
Quoted 1 line · On Wed, 26 May 2004 13:42:23 -0700 Shirley Ma <[email protected]> wrote:
Yes, same structure
ip_statsapplys to IPv4 as well.
Great, patch applied.
Re: [PATCH]Add new IPv6 MIBs counters support through netlink
In article <[email protected]> (at Wed, 26 May 2004 13:44:15 -0700), "David S. Miller" <[email protected]> says:
Quoted 6 lines
Quoted 1 line · On Wed, 26 May 2004 13:42:23 -0700 Shirley Ma <[email protected]> wrote:
Yes, same structure
ip_statsapplys to IPv4 as well.Great, patch applied.
I failed to comment because I've just waken up...
Hmm, why are you so hurrying?
It on -rc stage and 2.6.7 is coming.
Each people should moderate yourself...
Sorry, please exclude it for now.
Comments:
Without adding support for u64 counter, it does not make sense to add new interface. You can add new counter to the end of the structures.
This also contains per-interface statistics support.
(I rember that you said that) we should add idev into an route and avoid get/put idev.
I strongly do not want to poeple to change their code twice to support draft-ietf-ipv6-rfc2011-update-XX.txt.
I personally think this should be included in 2.7 phase.
--yoshfuji @ morning
Re: [PATCH]Add new IPv6 MIBs counters support through netlink
To clarify...
In article <[email protected]> (at Thu, 27 May 2004 08:08:28 +0900 (JST)), YOSHIFUJI Hideaki / 吉藤英明 <[email protected]> says:
Quoted 2 lines
I strongly do not want to poeple to change their code twice to support draft-ietf-ipv6-rfc2011-update-XX.txt.
(because of u64 things)
Quoted 1 line
I personally think this should be included in 2.7 phase.
(because of route things)
--yoshfuji
Re: [PATCH]Add new IPv6 MIBs counters support through netlink
In reply to YOSHIFUJI Hideaki / 吉藤英明Quoted 1 line · On Thu, 27 May 2004 08:08:28 +0900 (JST) YOSHIFUJI Hideaki / $B5HF#1QL@(B…
Hmm, why are you so hurrying?
I've only added it to my tree and have not pushed it off to Linus. I was in fact waiting for your feedback to occur first :-)
I see no way we will get the proper u64 support working any time soon, it is a hard problem to get that right and with acceptable performance on 32-bit platforms.
About idev in routes, we can add that as an optimization later.
Poor Shirley has waited long enough to get this feature integrated and given current knowledge it is the best working implementation we can come up with at this time.
Re: [PATCH]Add new IPv6 MIBs counters support through netlink
Quoted 1 line
Poor Shirley has waited long enough to get this feature integrated
and given current knowledge it is the best working implementation we can come up with at this time.
Appreciate your understanding. Maitaining this patch takes time.
Thanks
Shirley Ma
IBM Linux Technology Center
15300 SW Koll Parkway
Beaverton, OR 97006-6063
Phone: (503) 578-7638
FAX: (503) 578-3228
Re: [PATCH]Add new IPv6 MIBs counters support through netlink
In reply to YOSHIFUJI Hideaki / 吉藤英明Hi,Yoshifuji
Thanks for you comments!
Quoted 2 lines
Without adding support for u64 counter, it does not make sense to add new interface. You can add new counter to the end of the structures.
It's not good to add new counters to the end of the old structure. The mib
number and offset will be wrong.
Quoted 1 line
This also contains per-interface statistics support.
(I rember that you said that) we should add idev into an route and avoid get/put idev.
Only a few get/put idev there, not too many. And in some places there are no
route, no we can't use idev in route.
Quoted 1 line
I strongly do not want to poeple to change their code twice to support
draft-ietf-ipv6-rfc2011-update-XX.txt.
All the counters not just IP will be eventually 64 bits. We can fix it later. And
if we implement 64 counters here, there is performance issue on some architectures which don't support atmoic 64 for 32 bit platform.
Thanks
Shirley Ma
IBM Linux Technology Center
15300 SW Koll Parkway
Beaverton, OR 97006-6063
Phone: (503) 578-7638
FAX: (503) 578-3228
Re: [PATCH]Add new IPv6 MIBs counters support through netlink
In article <OFA97F4753.DC8C93AD-ON87256EA0.0080DAAB-07256EA0.00814B08@us.ibm.com> (at Wed, 26 May 2004 16:32:04 -0700), Shirley Ma <[email protected]> says:
Quoted 6 lines
Quoted 2 lines
Without adding support for u64 counter, it does not make sense to add new interface. You can add new counter to the end of the structures.
It's not good to add new counters to the end of the old structure. The mib
number and offset will be wrong.
I don't think so.
But, even if so, we can add only missing stats.
Quoted 7 lines
Quoted 1 line
This also contains per-interface statistics support.
(I rember that you said that) we should add idev into an route and avoid get/put idev.
Only a few get/put idev there, not too many. And in some places there are no
route, no we can't use idev in route.
okay.
Quoted 7 lines
Quoted 1 line
I strongly do not want to poeple to change their code twice to support
draft-ietf-ipv6-rfc2011-update-XX.txt.
All the counters not just IP will be eventually 64 bits. We can fix it later. And
if we implement 64 counters here, there is performance issue on some architectures which don't support atmoic 64 for 32 bit platform.
I strongly do not want to change interface twice to support these new statistics.
--yoshfuji @ driving traffic jam
Re: [PATCH]Add new IPv6 MIBs counters support through netlink
Quoted 7 lines · On Thu, 27 May 2004 08:58:12 +0900 (JST) YOSHIFUJI Hideaki / $B5HF#1QL@(B…
Quoted 4 lines
All the counters not just IP will be eventually 64 bits. We can fix it later. And
if we implement 64 counters here, there is performance issue on some architectures which don't support atmoic 64 for 32 bit platform.I strongly do not want to change interface twice to support these new statistics.
As a side note, I am worried about investing so much effort and expense if by the time we make 64-bit atomic counters work acceptably on 32-bit platforms we are all running Opteron machines :-)
PATCH 1/1 dst allocation problem in ndisc
In reply to Shirley MaWhen creating dst entry from ndisc, the dst entry of pmtu is not set, and the outout for this kind of dst entry is set to ip_output2 instead of ip_output. This could lead to send bigger packets through these des entries without fragmentation, and uninitialized pmtu could lead the network unreachable.
These problems are easy reproduced when configuring IPSEC for ipv6. IPSEC could pick up dst entry created by ndisc as child des entry if ndisc dst entry generated earlier. If sending bigger packets through IPSEC, the ip output2 will send bigger packets out, the driver will drop these packets on receiver side. Also the dst_entry pmtu will be 0, the network is unreachable.
The patch has been tested against 2.6.6. I am not sure why ndisc genereats dst entry with output equal to ip6_output2 not ip6_output. If ndisc sends bigger packets, it will break also.
Here is the patch against 2.6.6 kernel. Please review this patch.
Signature · 3 lines
Thanks Shirley Ma IBM Linux Technology Center
net/ipv6/ndisc.c +3 -3
@@ -395,7 +395,7 @@ndisc_flow_init (&fl,NDISC_NEIGHBOUR_ADVERTISEMENT , src_addr, daddr); - dst =ndisc_dst_alloc (dev, neigh, daddr, ip6_output2); + dst =ndisc_dst_alloc (dev, neigh, daddr, ip6_output);if (!dst)return ;
@@ -486,7 +486,7 @@ndisc_flow_init (&fl,NDISC_NEIGHBOUR_SOLICITATION , saddr, daddr); - dst =ndisc_dst_alloc (dev, neigh, daddr, ip6_output2); + dst =ndisc_dst_alloc (dev, neigh, daddr, ip6_output);if (!dst)return ;
@@ -562,7 +562,7 @@ndisc_flow_init (&fl,NDISC_ROUTER_SOLICITATION , saddr, daddr); - dst =ndisc_dst_alloc (dev,NULL , daddr, ip6_output2); + dst =ndisc_dst_alloc (dev,NULL , daddr, ip6_output);if (!dst)return ;
net/ipv6/route.c +52 -50
120 lines not on this page · raw message
Re: [PATCH] dst allocation problem in ndisc
In article <[email protected]> (at Wed, 9 Jun 2004 16:00:29 -0700), Shirley Ma <[email protected]> says:
Quoted 1 line
Here is the patch against 2.6.6 kernel. Please review this patch.
Basically, I agree.
One thing: you can minimize diff using function declaration.
--yoshfuji
Re: [PATCH] dst allocation problem in ndisc
Here it is.
Thanks
Shirley Ma
IBM Linux Technology Center
15300 SW Koll Parkway
Beaverton, OR 97006-6063
Phone: (503) 578-7638
FAX: (503) 578-3228
net/ipv6/ndisc.c +3 -3
@@ -395,7 +395,7 @@ndisc_flow_init (&fl,NDISC_NEIGHBOUR_ADVERTISEMENT , src_addr, daddr); - dst =ndisc_dst_alloc (dev, neigh, daddr, ip6_output2); + dst =ndisc_dst_alloc (dev, neigh, daddr, ip6_output);if (!dst)return ;
@@ -486,7 +486,7 @@ndisc_flow_init (&fl,NDISC_NEIGHBOUR_SOLICITATION , saddr, daddr); - dst =ndisc_dst_alloc (dev, neigh, daddr, ip6_output2); + dst =ndisc_dst_alloc (dev, neigh, daddr, ip6_output);if (!dst)return ;
@@ -562,7 +562,7 @@ndisc_flow_init (&fl,NDISC_ROUTER_SOLICITATION , saddr, daddr); - dst =ndisc_dst_alloc (dev,NULL , daddr, ip6_output2); + dst =ndisc_dst_alloc (dev,NULL , daddr, ip6_output);if (!dst)return ;
net/ipv6/route.c +4 -0
@@ -573,6 +573,8 @@/* Protected by rt6_lock. */ static struct dst_entry *ndisc_dst_gc_list; +static int ipv6_get_mtu (struct net_device *dev); +static inline unsigned int ipv6_advmss (unsigned int mtu); struct dst_entry *ndisc_dst_alloc(struct net_device *dev, struct neighbour *neigh,
@@ -598,6 +600,8 @@ rt->rt6i_metric =0 ;atomic_set (&rt->u.dst.__refcnt,1 ); rt->u.dst.metrics[RTAX_HOPLIMIT -1 ] =255 ; + rt->u.dst.metrics[RTAX_MTU -1 ] =ipv6_get_mtu (rt->rt6i_dev); + rt->u.dst.metrics[RTAX_ADVMSS -1 ] =ipv6_advmss (dst_pmtu (&rt->u.dst)); rt->u.dst.output = output;write_lock_bh (&rt6_lock);
Re: [PATCH] dst allocation problem in ndisc
Change ip6_output2 to static also. This patch is against 2.6.7-rc3.
Shirley Ma
IBM Linux Technology Center
15300 SW Koll Parkway
Beaverton, OR 97006-6063
Phone: (503) 578-7638
FAX: (503) 578-3228
include/net/ipv6.h +0 -1
@@ -356,7 +356,6 @@*/ extern int ip6_output (struct sk_buff **pskb); -extern int ip6_output2 (struct sk_buff **pskb);extern int ip6_forward (struct sk_buff *skb);extern int ip6_input (struct sk_buff *skb);extern int ip6_mc_input (struct sk_buff *skb);
net/ipv6/ip6_output.c +1 -1
@@ -107,7 +107,7 @@ } -int ip6_output2 (struct sk_buff **pskb) +static int ip6_output2 (struct sk_buff **pskb) {struct sk_buff *skb = *pskb;struct dst_entry *dst = skb->dst;
net/ipv6/ndisc.c +3 -3
@@ -395,7 +395,7 @@ndisc_flow_init (&fl,NDISC_NEIGHBOUR_ADVERTISEMENT , src_addr, daddr); - dst =ndisc_dst_alloc (dev, neigh, daddr, ip6_output2); + dst =ndisc_dst_alloc (dev, neigh, daddr, ip6_output);if (!dst)return ;
@@ -486,7 +486,7 @@ndisc_flow_init (&fl,NDISC_NEIGHBOUR_SOLICITATION , saddr, daddr); - dst =ndisc_dst_alloc (dev, neigh, daddr, ip6_output2); + dst =ndisc_dst_alloc (dev, neigh, daddr, ip6_output);if (!dst)return ;
@@ -562,7 +562,7 @@ndisc_flow_init (&fl,NDISC_ROUTER_SOLICITATION , saddr, daddr); - dst =ndisc_dst_alloc (dev,NULL , daddr, ip6_output2); + dst =ndisc_dst_alloc (dev,NULL , daddr, ip6_output);if (!dst)return ;
net/ipv6/route.c +4 -0
@@ -573,6 +573,8 @@/* Protected by rt6_lock. */ static struct dst_entry *ndisc_dst_gc_list; +static int ipv6_get_mtu (struct net_device *dev); +static inline unsigned int ipv6_advmss (unsigned int mtu); struct dst_entry *ndisc_dst_alloc(struct net_device *dev, struct neighbour *neigh,
@@ -598,6 +600,8 @@ rt->rt6i_metric =0 ;atomic_set (&rt->u.dst.__refcnt,1 ); rt->u.dst.metrics[RTAX_HOPLIMIT -1 ] =255 ; + rt->u.dst.metrics[RTAX_MTU -1 ] =ipv6_get_mtu (rt->rt6i_dev); + rt->u.dst.metrics[RTAX_ADVMSS -1 ] =ipv6_advmss (dst_pmtu (&rt->u.dst)); rt->u.dst.output = output;write_lock_bh (&rt6_lock);
Re: [PATCH] dst allocation problem in ndisc
Quoted 1 line · On Thu, 10 Jun 2004 14:46:20 -0600 Shirley Ma <[email protected]> wrote:
Change
ip6_output2to static also. This patch is against 2.6.7-rc3.
Patch applied, thanks a lot!
PATCH 1/1 some condition check error in ipsec v6
In reply to Shirley MaHere is a small patch for condition checking in ah6.c and esp6.c. This patch is against 2.6.6 kernel.
Signature · 3 lines
Thanks Shirley Ma IBM Linux Technology Center
net/ipv6/ah6.c +1 -1
@@ -360,7 +360,7 @@struct ip_auth_hdr *ah = (struct ip_auth_hdr *)(skb->data+offset);struct xfrm_state *x; -if (type !=ICMPV6_DEST_UNREACH || +if (type !=ICMPV6_DEST_UNREACH && type !=ICMPV6_PKT_TOOBIG )return ;
net/ipv6/esp6.c +1 -1
@@ -324,7 +324,7 @@struct ipv6_esp_hdr *esph = (struct ipv6_esp_hdr *)(skb->data+offset);struct xfrm_state *x; -if (type !=ICMPV6_DEST_UNREACH || +if (type !=ICMPV6_DEST_UNREACH && type !=ICMPV6_PKT_TOOBIG )return ;
Re: [PATCH] some condition check error in ipsec v6
In article <[email protected]> (at Wed, 9 Jun 2004 16:29:17 -0700), Shirley Ma <[email protected]> says:
Quoted 2 lines
Here is a small patch for condition checking in
ah6.candesp6.c. This patch is against 2.6.6 kernel.
good catch.
--yoshfuji
David S. Miller
AppliedRe: [PATCH] some condition check error in ipsec v6
In reply to Shirley MaQuoted 2 lines · On Wed, 9 Jun 2004 16:29:17 -0700 Shirley Ma <[email protected]> wrote:
Here is a small patch for condition checking in
ah6.candesp6.c. This patch is against 2.6.6 kernel.
Applied, thanks a lot!
PATCH 1/1 pmtu check conditions error in IPv6
In reply to Shirley MaHere is the patch. IPv6 pmtu check conditions were wrong in these two places. this patch is against 2.6.6 kernel. It has been tested under 2.6.5 kernel for IPsec.
Signature · 3 lines
Thanks Shirley Ma IBM Linux Technology Center
net/ipv6/route.c +2 -0
@@ -554,6 +554,8 @@if (mtu <dst_pmtu (dst) && rt6->rt6i_dst.plen ==128 ) { rt6->rt6i_flags |=RTF_MODIFIED ; +if (mtu <IPV6_MIN_MTU ) + mtu =IPV6_MIN_MTU ; dst->metrics[RTAX_MTU -1 ] = mtu; } }
net/ipv6/xfrm6_policy.c +4 -4
@@ -236,10 +236,10 @@ {struct dst_entry *path = dst->path; -if (mtu >=1280 && mtu <dst_pmtu (dst)) -return ; - - path->ops->update_pmtu (path, mtu); +if (mtu >=IPV6_MIN_MTU && mtu <dst_pmtu (dst)) + path->ops->update_pmtu (path, mtu); + +return ; }struct dst_ops xfrm6_dst_ops = {
Re: [PATCH] pmtu check conditions error in IPv6
Quoted 3 lines · On Wed, 26 May 2004 13:19:55 -0700 Shirley Ma <[email protected]> wrote:
Here is the patch. IPv6 pmtu check conditions were wrong in these two places. this patch is against 2.6.6 kernel. It has been tested under 2.6.5 kernel for IPsec.
Patch applied, thanks Shirley.
PATCH 1/1 IFA_MAX sets wrong in rtnetlink.h
In reply to Shirley MaA tiny patch here for 2.6.6 kernel.
Signature · 3 lines
Thanks Shirley Ma IBM Linux Technology Center
include/linux/rtnetlink.h +1 -1
@@ -348,7 +348,7 @@ IFA_MULTICAST }; -#define IFA_MAX IFA_CACHEINFO +#define IFA_MAX IFA_MULTICAST/* ifa_flags */
Re: [PATCH] IFA_MAX sets wrong in rtnetlink.h
Quoted 1 line · On Wed, 26 May 2004 13:50:39 -0700 Shirley Ma <[email protected]> wrote:
A tiny patch here for 2.6.6 kernel.
Good catch, patch applied.
Re: [PATCH] IFA_MAX sets wrong in rtnetlink.h
In article <[email protected]> (at Wed, 26 May 2004 13:56:10 -0700), "David S. Miller" <[email protected]> says:
Quoted 6 lines
Quoted 1 line · On Wed, 26 May 2004 13:50:39 -0700 Shirley Ma <[email protected]> wrote:
A tiny patch here for 2.6.6 kernel.
Good catch, patch applied.
BTW, how do you think of the code below to minimize diffs and risk of error when we add new item for enum?
enum {
:
IFA_MULTICAST,
__IFA_MAX
};#define IFA_MAX (__IFA_MAX - 1)
-----
enum {
:
IFA_CACHEINFO
};#define IFA_MAX IFA_CACHEINFO
enum {
:
IFA_CACHEINFO, /* changed to add "," */
IFA_MULTICAST /* added */
};
#define IFA_MAX IFA_MULTICAST /* changed */
--- vs ---
enum {
:
IFA_CACHEINFO,
__IFA_MAX
};#define IFA_MAX (__IFA_MAX - 1)
enum {
:
IFA_CACHEINFO,
IFA_MULTICAST, /* added */
__IFA_MAX
};#define IFA_MAX (__IFA_MAX - 1)
--yoshfuji
Re: [PATCH] IFA_MAX sets wrong in rtnetlink.h
Quoted 8 lines · On Fri, 28 May 2004 13:48:02 +0900 (JST) YOSHIFUJI Hideaki / $B5HF#1QL@(B…
enum { : IFA_CACHEINFO, IFA_MULTICAST, /* added */ __IFA_MAX };#define
IFA_MAX(__IFA_MAX- 1)
I like this last technique the best, one-line diffs :-)
Re: [PATCH] IFA_MAX sets wrong in rtnetlink.h
In article <[email protected]> (at Thu, 27 May 2004 22:07:56 -0700), "David S. Miller" <[email protected]> says:
Quoted 10 lines
Quoted 7 lines · On Fri, 28 May 2004 13:48:02 +0900 (JST) YOSHIFUJI Hideaki / $B5HF#1QL@(B…
enum { : IFA_CACHEINFO, IFA_MULTICAST, /* added */ __IFA_MAX };
Quoted 3 lines
Quoted 1 line
#define
IFA_MAX(__IFA_MAX- 1)I like this last technique the best, one-line diffs :-)
Ok, I'll do this.
--yoshfuji
Re: [PATCH] IFA_MAX sets wrong in rtnetlink.h
In article <[email protected]> (at Fri, 28 May 2004 14:12:00 +0900 (JST)), YOSHIFUJI Hideaki / 吉藤英明 <[email protected]> says:
Quoted 12 lines
In article <[email protected]> (at Thu, 27 May 2004 22:07:56 -0700), "David S. Miller" <[email protected]> says:
Quoted 10 lines
Quoted 7 lines · On Fri, 28 May 2004 13:48:02 +0900 (JST) YOSHIFUJI Hideaki / 吉藤英明…
enum { : IFA_CACHEINFO, IFA_MULTICAST, /* added */ __IFA_MAX };
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
#define
IFA_MAX(__IFA_MAX- 1)I like this last technique the best, one-line diffs :-)
Ok, I'll do this.
Here's the patch for 2.6. Please apply on top of the Sirley's patch.
include/linux/rtnetlink.h +24 -14
@@ -118,9 +118,10 @@RTN_THROW ,/* Not in this table */ RTN_NAT ,/* Translate this address */ RTN_XRESOLVE ,/* Use external resolver */ + __RTN_MAX }; -#define RTN_MAX RTN_XRESOLVE +#define RTN_MAX (__RTN_MAX - 1)/* rtm_protocol */
@@ -183,9 +184,10 @@/* User defined values */ RT_TABLE_DEFAULT =253 ,RT_TABLE_MAIN =254 , - RT_TABLE_LOCAL=255 +RT_TABLE_LOCAL =255 , + __RT_TABLE_MAX }; -#define RT_TABLE_MAX RT_TABLE_LOCAL +#define RT_TABLE_MAX (__RT_TABLE_MAX - 1)
@@ -207,9 +209,10 @@RTA_FLOW ,RTA_CACHEINFO ,RTA_SESSION , + __RTA_MAX }; -#define RTA_MAX RTA_SESSION +#define RTA_MAX (__RTA_MAX - 1)#define RTM_RTA (r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct rtmsg))))#define RTM_PAYLOAD (n) NLMSG_PAYLOAD(n,sizeof(struct rtmsg))
@@ -294,9 +297,10 @@#define RTAX_INITCWND RTAX_INITCWND RTAX_FEATURES,#define RTAX_FEATURES RTAX_FEATURES + __RTAX_MAX }; -#define RTAX_MAX RTAX_FEATURES +#define RTAX_MAX (__RTAX_MAX - 1)#define RTAX_FEATURE_ECN 0x00000001#define RTAX_FEATURE_SACK 0x00000002
@@ -345,10 +349,11 @@IFA_BROADCAST ,IFA_ANYCAST ,IFA_CACHEINFO , - IFA_MULTICAST +IFA_MULTICAST , + __IFA_MAX }; -#define IFA_MAX IFA_MULTICAST +#define IFA_MAX (__IFA_MAX - 1)/* ifa_flags */
@@ -399,10 +404,11 @@NDA_UNSPEC ,NDA_DST ,NDA_LLADDR , - NDA_CACHEINFO +NDA_CACHEINFO , + __NDA_MAX }; -#define NDA_MAX NDA_CACHEINFO +#define NDA_MAX (__NDA_MAX - 1)#define NDA_RTA (r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ndmsg))))#define NDA_PAYLOAD (n) NLMSG_PAYLOAD(n,sizeof(struct ndmsg))
@@ -485,9 +491,10 @@PREFIX_UNSPEC ,PREFIX_ADDRESS ,PREFIX_CACHEINFO , + __PREFIX_MAX }; -#define PREFIX_MAX PREFIX_CACHEINFO +#define PREFIX_MAX (__PREFIX_MAX - 1)struct prefix_cacheinfo {
@@ -549,10 +556,11 @@#define IFLA_WIRELESS IFLA_WIRELESS IFLA_PROTINFO, /* Protocol specific information for a link */#define IFLA_PROTINFO IFLA_PROTINFO + __IFLA_MAX }; -#define IFLA_MAX IFLA_PROTINFO +#define IFLA_MAX (__IFLA_MAX - 1)#define IFLA_RTA (r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ifinfomsg))))#define IFLA_PAYLOAD (n) NLMSG_PAYLOAD(n,sizeof(struct ifinfomsg))
@@ -595,8 +603,11 @@ IFLA_INET6_STATS, /* statistics */IFLA_INET6_MCAST ,/* MC things. What of them? */ IFLA_INET6_CACHEINFO ,/* time values and max reasm size */ + __IFLA_INET6_MAX }; +#define IFLA_INET6_MAX (__IFLA_INET6_MAX - 1) +struct ifla_cacheinfo {__u32 max_reasm_len;
@@ -605,8 +616,6 @@__u32 retrans_time; }; -#define IFLA_INET6_MAX IFLA_INET6_CACHEINFO -/***************************************************************** * Traffic control messages. ****/
@@ -630,9 +639,10 @@TCA_STATS ,TCA_XSTATS ,TCA_RATE , + __TCA_MAX }; -#define TCA_MAX TCA_RATE +#define TCA_MAX (__TCA_MAX - 1)#define TCA_RTA (r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct tcmsg))))#define TCA_PAYLOAD (n) NLMSG_PAYLOAD(n,sizeof(struct tcmsg))
include/linux/pkt_cls.h +13 -7
@@ -24,11 +24,12 @@TCA_POLICE_RATE ,TCA_POLICE_PEAKRATE ,TCA_POLICE_AVRATE , - TCA_POLICE_RESULT +TCA_POLICE_RESULT , #define TCA_POLICE_RESULT TCA_POLICE_RESULT + __TCA_POLICE_MAX }; -#define TCA_POLICE_MAX TCA_POLICE_RESULT +#define TCA_POLICE_MAX (__TCA_POLICE_MAX - 1)/* U32 filters */
@@ -49,9 +50,10 @@TCA_U32_DIVISOR ,TCA_U32_SEL ,TCA_U32_POLICE , + __TCA_U32_MAX }; -#define TCA_U32_MAX TCA_U32_POLICE +#define TCA_U32_MAX (__TCA_U32_MAX - 1)struct tc_u32_key {
@@ -97,9 +99,10 @@TCA_RSVP_SRC ,TCA_RSVP_PINFO ,TCA_RSVP_POLICE , + __TCA_RSVP_MAX }; -#define TCA_RSVP_MAX TCA_RSVP_POLICE +#define TCA_RSVP_MAX (__TCA_RSVP_MAX - 1)struct tc_rsvp_gpi {
@@ -127,9 +130,10 @@TCA_ROUTE4_FROM ,TCA_ROUTE4_IIF ,TCA_ROUTE4_POLICE , + __TCA_ROUTE4_MAX }; -#define TCA_ROUTE4_MAX TCA_ROUTE4_POLICE +#define TCA_ROUTE4_MAX (__TCA_ROUTE4_MAX - 1)/* FW filter */
@@ -139,9 +143,10 @@TCA_FW_UNSPEC ,TCA_FW_CLASSID ,TCA_FW_POLICE , + __TCA_FW_MAX }; -#define TCA_FW_MAX TCA_FW_POLICE +#define TCA_FW_MAX (__TCA_FW_MAX - 1)/* TC index filter */
@@ -154,8 +159,9 @@TCA_TCINDEX_FALL_THROUGH ,TCA_TCINDEX_CLASSID ,TCA_TCINDEX_POLICE , + __TCA_TCINDEX_MAX }; -#define TCA_TCINDEX_MAX TCA_TCINDEX_POLICE +#define TCA_TCINDEX_MAX (__TCA_TCINDEX_MAX - 1)#endif
include/linux/xfrm.h +2 -1
@@ -152,8 +152,9 @@XFRMA_ALG_COMP ,/* struct xfrm_algo */ XFRMA_ENCAP ,/* struct xfrm_algo + struct xfrm_encap_tmpl */ XFRMA_TMPL ,/* 1 or more struct xfrm_user_tmpl */ + __XFRMA_MAX -#define XFRMA_MAX XFRMA_TMPL +#define XFRMA_MAX (__XFRMA_MAX - 1) };struct xfrm_usersa_info {
Signature · 2 lines
Hideaki YOSHIFUJI @ USAGI Project <[email protected]> GPG FP: 9022 65EB 1ECF 3AD1 0BDF 80D8 4807 F894 E062 0EEA
David S. Miller
AppliedRe: [PATCH] IFA_MAX sets wrong in rtnetlink.h
Quoted 1 line · On Fri, 28 May 2004 18:25:38 +0900 (JST) YOSHIFUJI Hideaki / $B5HF#1QL@(B…
Here's the patch for 2.6. Please apply on top of the Sirley's patch.
Applied, thanks.
Re: [PATCH] IFA_MAX sets wrong in rtnetlink.h
In reply to YOSHIFUJI Hideaki / 吉藤英明In article <[email protected]> (at Fri, 28 May 2004 14:12:00 +0900 (JST)), YOSHIFUJI Hideaki / 吉藤英明 <[email protected]> says:
Quoted 12 lines
In article <[email protected]> (at Thu, 27 May 2004 22:07:56 -0700), "David S. Miller" <[email protected]> says:
Quoted 10 lines
Quoted 7 lines · On Fri, 28 May 2004 13:48:02 +0900 (JST) YOSHIFUJI Hideaki / 吉藤英明…
enum { : IFA_CACHEINFO, IFA_MULTICAST, /* added */ __IFA_MAX };
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
#define
IFA_MAX(__IFA_MAX- 1)I like this last technique the best, one-line diffs :-)
Ok, I'll do this.
Here's the patch for 2.4.
===== include/linux/pkt_cls.h 1.1 vs edited =====
include/linux/pkt_cls.h +13 -7
@@ -24,11 +24,12 @@TCA_POLICE_RATE ,TCA_POLICE_PEAKRATE ,TCA_POLICE_AVRATE , - TCA_POLICE_RESULT +TCA_POLICE_RESULT , #define TCA_POLICE_RESULT TCA_POLICE_RESULT + __TCA_POLICE_MAX }; -#define TCA_POLICE_MAX TCA_POLICE_RESULT +#define TCA_POLICE_MAX (__TCA_POLICE_MAX - 1)/* U32 filters */
@@ -49,9 +50,10 @@TCA_U32_DIVISOR ,TCA_U32_SEL ,TCA_U32_POLICE , + __TCA_U32_MAX }; -#define TCA_U32_MAX TCA_U32_POLICE +#define TCA_U32_MAX (__TCA_U32_MAX - 1)struct tc_u32_key {
@@ -97,9 +99,10 @@TCA_RSVP_SRC ,TCA_RSVP_PINFO ,TCA_RSVP_POLICE , + __TCA_RSVP_MAX }; -#define TCA_RSVP_MAX TCA_RSVP_POLICE +#define TCA_RSVP_MAX (__TCA_RSVP_MAX - 1)struct tc_rsvp_gpi {
@@ -127,9 +130,10 @@TCA_ROUTE4_FROM ,TCA_ROUTE4_IIF ,TCA_ROUTE4_POLICE , + __TCA_ROUTE4_MAX }; -#define TCA_ROUTE4_MAX TCA_ROUTE4_POLICE +#define TCA_ROUTE4_MAX (__TCA_ROUTE4_MAX - 1)/* FW filter */
@@ -139,9 +143,10 @@TCA_FW_UNSPEC ,TCA_FW_CLASSID ,TCA_FW_POLICE , + __TCA_FW_MAX }; -#define TCA_FW_MAX TCA_FW_POLICE +#define TCA_FW_MAX (__TCA_FW_MAX - 1)/* TC index filter */
@@ -154,8 +159,9 @@TCA_TCINDEX_FALL_THROUGH ,TCA_TCINDEX_CLASSID ,TCA_TCINDEX_POLICE , + __TCA_TCINDEX_MAX }; -#define TCA_TCINDEX_MAX TCA_TCINDEX_POLICE +#define TCA_TCINDEX_MAX (__TCA_TCINDEX_MAX - 1)#endif
===== include/linux/rtnetlink.h 1.11 vs edited =====
include/linux/rtnetlink.h +22 -13
@@ -113,9 +113,10 @@RTN_THROW ,/* Not in this table */ RTN_NAT ,/* Translate this address */ RTN_XRESOLVE ,/* Use external resolver */ + __RTN_MAX }; -#define RTN_MAX RTN_XRESOLVE +#define RTN_MAX (__RTN_MAX - 1)/* rtm_protocol */
@@ -178,9 +179,10 @@/* User defined values */ RT_TABLE_DEFAULT =253 ,RT_TABLE_MAIN =254 , - RT_TABLE_LOCAL=255 +RT_TABLE_LOCAL =255 , + __RT_TABLE_MAX }; -#define RT_TABLE_MAX RT_TABLE_LOCAL +#define RT_TABLE_MAX (__RT_TABLE_MAX - 1)
@@ -200,10 +202,11 @@RTA_MULTIPATH ,RTA_PROTOINFO ,RTA_FLOW , - RTA_CACHEINFO +RTA_CACHEINFO , + __RTA_MAX }; -#define RTA_MAX RTA_CACHEINFO +#define RTA_MAX (__RTA_MAX - 1)#define RTM_RTA (r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct rtmsg))))#define RTM_PAYLOAD (n) NLMSG_PAYLOAD(n,sizeof(struct rtmsg))
@@ -282,9 +285,10 @@#define RTAX_ADVMSS RTAX_ADVMSS RTAX_REORDERING,#define RTAX_REORDERING RTAX_REORDERING + __RTAX_MAX }; -#define RTAX_MAX RTAX_REORDERING +#define RTAX_MAX (__RTAX_MAX - 1)
@@ -309,10 +313,11 @@IFA_LABEL ,IFA_BROADCAST ,IFA_ANYCAST , - IFA_CACHEINFO +IFA_CACHEINFO , + __IFA_MAX }; -#define IFA_MAX IFA_CACHEINFO +#define IFA_MAX (__IFA_MAX - 1)/* ifa_flags */
@@ -360,10 +365,11 @@NDA_UNSPEC ,NDA_DST ,NDA_LLADDR , - NDA_CACHEINFO +NDA_CACHEINFO , + __NDA_MAX }; -#define NDA_MAX NDA_CACHEINFO +#define NDA_MAX (__NDA_MAX - 1)#define NDA_RTA (r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ndmsg))))#define NDA_PAYLOAD (n) NLMSG_PAYLOAD(n,sizeof(struct ndmsg))
@@ -448,10 +454,11 @@#define IFLA_WIRELESS IFLA_WIRELESS IFLA_PROTINFO, /* Protocol specific information for a link */#define IFLA_PROTINFO IFLA_PROTINFO + __IFLA_MAX }; -#define IFLA_MAX IFLA_PROTINFO +#define IFLA_MAX (__IFLA_MAX - 1)#define IFLA_RTA (r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ifinfomsg))))#define IFLA_PAYLOAD (n) NLMSG_PAYLOAD(n,sizeof(struct ifinfomsg))
@@ -493,9 +500,10 @@IFLA_INET6_CONF ,/* sysctl parameters */ IFLA_INET6_STATS ,/* statistics */ IFLA_INET6_MCAST ,/* MC things. What of them? */ + __IFLA_INET6_MAX }; -#define IFLA_INET6_MAX IFLA_INET6_MCAST +#define IFLA_INET6_MAX (__IFLA_INET6_MAX - 1)/***************************************************************** * Traffic control messages.
@@ -520,9 +528,10 @@TCA_STATS ,TCA_XSTATS ,TCA_RATE , + __TCA_MAX }; -#define TCA_MAX TCA_RATE +#define TCA_MAX (__TCA_MAX - 1)#define TCA_RTA (r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct tcmsg))))#define TCA_PAYLOAD (n) NLMSG_PAYLOAD(n,sizeof(struct tcmsg))
Signature · 2 lines
Hideaki YOSHIFUJI @ USAGI Project <[email protected]> GPG FP: 9022 65EB 1ECF 3AD1 0BDF 80D8 4807 F894 E062 0EEA