Re: /proc/net/* read drops data
15 messages,
3 authors,
2003-09-11 · open the first message on its own page
Hello.
In article [off-list ref] (at Wed, 27 Aug 2003 19:58:17 -0400 (EDT)), Ricky Beam [off-list ref] says:
On Wed, 27 Aug 2003, Ricky Beam wrote: quoted This smells like a simple "off by one" bug, but I've been too busy to go
look at the code.
Ah hah! it's a block size problem... netstat reads 1024 at a time.
Using dd...
[root:pts/5{9}]gir:~/[7:55pm]:dd if=/proc/net/udp bs=1024 | wc
2+1 records in
2+1 records out
18 216 2304
[root:pts/5{9}]gir:~/[7:56pm]:dd if=/proc/net/udp bs=2048 | wc
1+1 records in
1+1 records out
19 228 2432 :
Please try this patch.
D: Fixing a bug that reading /proc/net/{udp,udp6} may drop some data
Index: linux-2.6/net/ipv4/udp.c
===================================================================
RCS file: /home/cvs/linux-2.5/net/ipv4/udp.c,v
retrieving revision 1.38
diff -u -r1.38 udp.c --- linux-2.6/net/ipv4/udp.c 14 Aug 2003 06:00:04 -0000 1.38
+++ linux-2.6/net/ipv4/udp.c 3 Sep 2003 05:30:52 -0000 @@ -1349,64 +1349,65 @@
/* ------------------------------------------------------------------------ */
#ifdef CONFIG_PROC_FS
- static __inline__ struct sock * udp_get_bucket ( struct seq_file * seq , loff_t * pos )
+ static struct sock * udp_get_first ( struct seq_file * seq )
{
- int i ;
struct sock * sk ;
- struct hlist_node * node ;
- loff_t l = * pos ;
struct udp_iter_state * state = seq -> private ;
- for (; state -> bucket < UDP_HTABLE_SIZE ; ++ state -> bucket ) {
- i = 0 ;
+ for ( state -> bucket = 0 ; state -> bucket < UDP_HTABLE_SIZE ; ++ state -> bucket ) {
+ struct hlist_node * node ;
sk_for_each ( sk , node , & udp_hash [ state -> bucket ]) {
- if ( sk -> sk_family != state -> family ) {
- ++ i ;
- continue ;
- }
- if ( l -- ) {
- ++ i ;
- continue ;
- }
- * pos = i ;
- goto out ;
+ if ( sk -> sk_family == state -> family )
+ goto found ;
}
}
sk = NULL ;
- out :
+ found :
return sk ;
}
+ static struct sock * udp_get_next ( struct seq_file * seq , struct sock * sk )
+ {
+ struct udp_iter_state * state = seq -> private ;
+
+ do {
+ sk = sk_next ( sk );
+ try_again :
+ ;
+ } while ( sk && sk -> sk_family != state -> family );
+
+ if ( ! sk && ++ state -> bucket < UDP_HTABLE_SIZE ) {
+ sk = sk_head ( & udp_hash [ state -> bucket ]);
+ goto try_again ;
+ }
+ return sk ;
+ }
+
+ static struct sock * udp_get_idx ( struct seq_file * seq , loff_t pos )
+ {
+ struct sock * sk = udp_get_first ( seq );
+
+ if ( sk )
+ while ( pos && ( sk = udp_get_next ( seq , sk )) != NULL )
+ -- pos ;
+ return pos ? NULL : sk ;
+ }
+
static void * udp_seq_start ( struct seq_file * seq , loff_t * pos )
{
read_lock ( & udp_hash_lock );
- return * pos ? udp_get_bucket ( seq , pos ) : ( void * ) 1 ;
+ return * pos ? udp_get_idx ( seq , * pos -1 ) : ( void * ) 1 ;
}
static void * udp_seq_next ( struct seq_file * seq , void * v , loff_t * pos )
{
struct sock * sk ;
- struct hlist_node * node ;
- struct udp_iter_state * state ;
-
- if ( v == ( void * ) 1 ) {
- sk = udp_get_bucket ( seq , pos );
- goto out ;
- }
- state = seq -> private ;
+ if ( v == ( void * ) 1 )
+ sk = udp_get_idx ( seq , 0 );
+ else
+ sk = udp_get_next ( seq , v );
- sk = v ;
- sk_for_each_continue ( sk , node )
- if ( sk -> sk_family == state -> family )
- goto out ;
-
- if ( ++ state -> bucket >= UDP_HTABLE_SIZE )
- goto out ;
-
- * pos = 0 ;
- sk = udp_get_bucket ( seq , pos );
- out :
++* pos ;
return sk ;
}
--
Hideaki YOSHIFUJI @ USAGI Project <yoshfuji@linux-ipv6.org>
GPG FP: 9022 65EB 1ECF 3AD1 0BDF 80D8 4807 F894 E062 0EEA
On Wed, 03 Sep 2003 16:07:33 +0900 (JST)
YOSHIFUJI Hideaki / _$B5HF#1QL@ [off-list ref] wrote:
D: Fixing a bug that reading /proc/net/{udp,udp6} may drop some data
This fix looks good to me. Applied.
On Thu, 4 Sep 2003, David S. Miller wrote: quoted D: Fixing a bug that reading /proc/net/{udp,udp6} may drop some data
This fix looks good to me. Applied.
That might fix udp, but that's not the only one to be fixed. I'll compile
a list. (tcp for sure.)
--Ricky
On Thu, 4 Sep 2003, David S. Miller wrote: quoted D: Fixing a bug that reading /proc/net/{udp,udp6} may drop some data
This fix looks good to me. Applied.
The list:
(file) (bs=1) (bs=10000)
/proc/net/igmp 122 191
/proc/net/route 128 384
/proc/net/rt_acct 0 4096
/proc/net/rt_cache 384 512
/proc/net/tcp 1800 1950
/proc/net/udp 1024 1152
(I don't have ipv6 enabled)
--Ricky
In article [off-list ref] (at Thu, 4 Sep 2003 12:25:16 -0400 (EDT)), Ricky Beam [off-list ref] says:
The list:
(file) (bs=1) (bs=10000)
/proc/net/igmp 122 191
/proc/net/route 128 384
/proc/net/rt_acct 0 4096
/proc/net/rt_cache 384 512
/proc/net/tcp 1800 1950
/proc/net/udp 1024 1152
Okay, I'll seek the code.
--yoshfuji
In article [off-list ref] (at Thu, 4 Sep 2003 12:25:16 -0400 (EDT)), Ricky Beam [off-list ref] says:
quoted This fix looks good to me. Applied.
The list:
(file) (bs=1) (bs=10000)
/proc/net/igmp 122 191
/proc/net/route 128 384
/proc/net/rt_acct 0 4096
/proc/net/rt_cache 384 512
/proc/net/tcp 1800 1950
/proc/net/udp 1024 1152
Well, I'm about to post 3 patches.
[1/3] /proc/net/{igmp,msfilter,raw,rt_cache,ip6_flowlabel,msfilter6,raw6} may drop some data
[2/3] /proc/net/if_inet6 may drop some data
[3/3] clean up /proc/net/{anycast6,igmp6}
Note 0: These confilct with SEQ_START_TOKEN patches;
I'll regenerate if SEQ_START_TOKEN accepted.
Note 1: /proc/net/rt_acct does not use seq_file
Note 2: /proc/net/{route,tcp,tcp6} is not fixed by these
--
Hideaki YOSHIFUJI @ USAGI Project [off-list ref]
GPG FP: 9022 65EB 1ECF 3AD1 0BDF 80D8 4807 F894 E062 0EEA
[1/3] /proc/net/{igmp,msfilter,raw,rt_cache,ip6_flowlabel,msfilter6,raw6} may drop some data
Index: linux-2.6/net/ipv4/igmp.c
===================================================================
RCS file: /home/cvs/linux-2.5/net/ipv4/igmp.c,v
retrieving revision 1.34
diff -u -r1.34 igmp.c --- linux-2.6/net/ipv4/igmp.c 1 Sep 2003 05:52:50 -0000 1.34
+++ linux-2.6/net/ipv4/igmp.c 6 Sep 2003 04:23:07 -0000 @@ -2162,7 +2162,7 @@
static void * igmp_mc_seq_start ( struct seq_file * seq , loff_t * pos )
{
read_lock ( & dev_base_lock );
- return * pos ? igmp_mc_get_idx ( seq , * pos ) : ( void * ) 1 ;
+ return * pos ? igmp_mc_get_idx ( seq , * pos - 1 ) : ( void * ) 1 ;
}
static void * igmp_mc_seq_next ( struct seq_file * seq , void * v , loff_t * pos ) @@ -2337,7 +2337,7 @@
static void * igmp_mcf_seq_start ( struct seq_file * seq , loff_t * pos )
{
read_lock ( & dev_base_lock );
- return * pos ? igmp_mcf_get_idx ( seq , * pos ) : ( void * ) 1 ;
+ return * pos ? igmp_mcf_get_idx ( seq , * pos - 1 ) : ( void * ) 1 ;
}
static void * igmp_mcf_seq_next ( struct seq_file * seq , void * v , loff_t * pos ) Index: linux-2.6/net/ipv4/raw.c
===================================================================
RCS file: /home/cvs/linux-2.5/net/ipv4/raw.c,v
retrieving revision 1.35
diff -u -r1.35 raw.c --- linux-2.6/net/ipv4/raw.c 11 Jul 2003 04:06:16 -0000 1.35
+++ linux-2.6/net/ipv4/raw.c 6 Sep 2003 04:23:07 -0000 @@ -736,7 +736,7 @@
static void * raw_seq_start ( struct seq_file * seq , loff_t * pos )
{
read_lock ( & raw_v4_lock );
- return * pos ? raw_get_idx ( seq , * pos ) : ( void * ) 1 ;
+ return * pos ? raw_get_idx ( seq , * pos - 1 ) : ( void * ) 1 ;
}
static void * raw_seq_next ( struct seq_file * seq , void * v , loff_t * pos ) Index: linux-2.6/net/ipv4/route.c
===================================================================
RCS file: /home/cvs/linux-2.5/net/ipv4/route.c,v
retrieving revision 1.58
diff -u -r1.58 route.c --- linux-2.6/net/ipv4/route.c 1 Sep 2003 05:52:50 -0000 1.58
+++ linux-2.6/net/ipv4/route.c 6 Sep 2003 04:23:07 -0000 @@ -259,7 +259,7 @@
static void * rt_cache_seq_start ( struct seq_file * seq , loff_t * pos )
{
- return * pos ? rt_cache_get_idx ( seq , * pos ) : ( void * ) 1 ;
+ return * pos ? rt_cache_get_idx ( seq , * pos - 1 ) : ( void * ) 1 ;
}
static void * rt_cache_seq_next ( struct seq_file * seq , void * v , loff_t * pos ) Index: linux-2.6/net/ipv6/ip6_flowlabel.c
===================================================================
RCS file: /home/cvs/linux-2.5/net/ipv6/ip6_flowlabel.c,v
retrieving revision 1.8
diff -u -r1.8 ip6_flowlabel.c --- linux-2.6/net/ipv6/ip6_flowlabel.c 2 Sep 2003 14:48:07 -0000 1.8
+++ linux-2.6/net/ipv6/ip6_flowlabel.c 6 Sep 2003 04:23:07 -0000 @@ -603,7 +603,7 @@
static void * ip6fl_seq_start ( struct seq_file * seq , loff_t * pos )
{
read_lock_bh ( & ip6_fl_lock );
- return * pos ? ip6fl_get_idx ( seq , * pos ) : ( void * ) 1 ;
+ return * pos ? ip6fl_get_idx ( seq , * pos - 1 ) : ( void * ) 1 ;
}
static void * ip6fl_seq_next ( struct seq_file * seq , void * v , loff_t * pos ) Index: linux-2.6/net/ipv6/mcast.c
===================================================================
RCS file: /home/cvs/linux-2.5/net/ipv6/mcast.c,v
retrieving revision 1.31
diff -u -r1.31 mcast.c --- linux-2.6/net/ipv6/mcast.c 1 Sep 2003 05:52:50 -0000 1.31
+++ linux-2.6/net/ipv6/mcast.c 6 Sep 2003 04:23:07 -0000 @@ -2278,7 +2278,7 @@
static void * igmp6_mcf_seq_start ( struct seq_file * seq , loff_t * pos )
{
read_lock ( & dev_base_lock );
- return * pos ? igmp6_mcf_get_idx ( seq , * pos ) : ( void * ) 1 ;
+ return * pos ? igmp6_mcf_get_idx ( seq , * pos - 1 ) : ( void * ) 1 ;
}
static void * igmp6_mcf_seq_next ( struct seq_file * seq , void * v , loff_t * pos ) Index: linux-2.6/net/ipv6/raw.c
===================================================================
RCS file: /home/cvs/linux-2.5/net/ipv6/raw.c,v
retrieving revision 1.37
diff -u -r1.37 raw.c --- linux-2.6/net/ipv6/raw.c 18 Aug 2003 10:14:52 -0000 1.37
+++ linux-2.6/net/ipv6/raw.c 6 Sep 2003 04:23:07 -0000 @@ -961,7 +961,7 @@
static void * raw6_seq_start ( struct seq_file * seq , loff_t * pos )
{
read_lock ( & raw_v6_lock );
- return * pos ? raw6_get_idx ( seq , * pos ) : ( void * ) 1 ;
+ return * pos ? raw6_get_idx ( seq , * pos - 1 ) : ( void * ) 1 ;
}
static void * raw6_seq_next ( struct seq_file * seq , void * v , loff_t * pos )
--
Hideaki YOSHIFUJI @ USAGI Project <yoshfuji@linux-ipv6.org>
GPG FP: 9022 65EB 1ECF 3AD1 0BDF 80D8 4807 F894 E062 0EEA
[2/3] /proc/net/if_inet6 may drop some data
Index: linux-2.6/net/ipv6/addrconf.c
===================================================================
RCS file: /home/cvs/linux-2.5/net/ipv6/addrconf.c,v
retrieving revision 1.52
diff -u -r1.52 addrconf.c --- linux-2.6/net/ipv6/addrconf.c 4 Sep 2003 15:47:07 -0000 1.52
+++ linux-2.6/net/ipv6/addrconf.c 6 Sep 2003 04:23:07 -0000 @@ -2149,59 +2149,65 @@
int bucket ;
};
- static inline struct inet6_ifaddr * if6_get_bucket ( struct seq_file * seq , loff_t * pos )
+ static struct inet6_ifaddr * if6_get_first ( struct seq_file * seq )
{
- int i ;
struct inet6_ifaddr * ifa = NULL ;
- loff_t l = * pos ;
struct if6_iter_state * state = seq -> private ;
- for (; state -> bucket < IN6_ADDR_HSIZE ; ++ state -> bucket )
- for ( i = 0 , ifa = inet6_addr_lst [ state -> bucket ]; ifa ; ++ i , ifa = ifa -> lst_next ) {
- if ( l -- )
- continue ;
- * pos = i ;
- goto out ;
- }
- out :
+ for ( state -> bucket = 0 ; state -> bucket < IN6_ADDR_HSIZE ; ++ state -> bucket ) {
+ ifa = inet6_addr_lst [ state -> bucket ];
+ if ( ifa )
+ break ;
+ }
+ return ifa ;
+ }
+
+ static struct inet6_ifaddr * if6_get_next ( struct seq_file * seq , struct inet6_ifaddr * ifa )
+ {
+ struct if6_iter_state * state = seq -> private ;
+
+ ifa = ifa -> lst_next ;
+ try_again :
+ if ( ! ifa && ++ state -> bucket < IN6_ADDR_HSIZE ) {
+ ifa = inet6_addr_lst [ state -> bucket ];
+ goto try_again ;
+ }
return ifa ;
}
+ static struct inet6_ifaddr * if6_get_idx ( struct seq_file * seq , loff_t pos )
+ {
+ struct inet6_ifaddr * ifa = if6_get_first ( seq );
+
+ if ( ifa )
+ while ( pos && ( ifa = if6_get_next ( seq , ifa )) != NULL )
+ -- pos ;
+ return pos ? NULL : ifa ;
+ }
+
static void * if6_seq_start ( struct seq_file * seq , loff_t * pos )
{
read_lock_bh ( & addrconf_hash_lock );
- return * pos ? if6_get_bucket ( seq , pos ) : ( void * ) 1 ;
+ return if6_get_idx ( seq , * pos );
}
static void * if6_seq_next ( struct seq_file * seq , void * v , loff_t * pos )
{
struct inet6_ifaddr * ifa ;
- struct if6_iter_state * state ;
-
- if ( v == ( void * ) 1 ) {
- ifa = if6_get_bucket ( seq , pos );
- goto out ;
- }
-
- state = seq -> private ;
-
- ifa = v ;
- ifa = ifa -> lst_next ;
- if ( ifa )
- goto out ;
-
- if ( ++ state -> bucket >= IN6_ADDR_HSIZE )
- goto out ;
- * pos = 0 ;
- ifa = if6_get_bucket ( seq , pos );
- out :
+ ifa = if6_get_next ( seq , v );
++* pos ;
return ifa ;
}
- static inline void if6_iface_seq_show ( struct seq_file * seq , struct inet6_ifaddr * ifp )
+ static void if6_seq_stop ( struct seq_file * seq , void * v )
+ {
+ read_unlock_bh ( & addrconf_hash_lock );
+ }
+
+ static int if6_seq_show ( struct seq_file * seq , void * v )
{
+ struct inet6_ifaddr * ifp = ( struct inet6_ifaddr * ) v ;
seq_printf ( seq ,
"%04x%04x%04x%04x%04x%04x%04x%04x %02x %02x %02x %02x %8s \n " ,
NIP6 ( ifp -> addr ), @@ -2210,20 +2216,7 @@
ifp -> scope ,
ifp -> flags ,
ifp -> idev -> dev -> name );
- }
-
- static int if6_seq_show ( struct seq_file * seq , void * v )
- {
- if ( v == ( void * ) 1 )
- return 0 ;
- else
- if6_iface_seq_show ( seq , v );
return 0 ;
- }
-
- static void if6_seq_stop ( struct seq_file * seq , void * v )
- {
- read_unlock_bh ( & addrconf_hash_lock );
}
static struct seq_operations if6_seq_ops = {
--
Hideaki YOSHIFUJI @ USAGI Project <yoshfuji@linux-ipv6.org>
GPG FP: 9022 65EB 1ECF 3AD1 0BDF 80D8 4807 F894 E062 0EEA
[3/3] clean up /proc/net/{anycast6,igmp6}
Index: linux-2.6/net/ipv6/anycast.c
===================================================================
RCS file: /home/cvs/linux-2.5/net/ipv6/anycast.c,v
retrieving revision 1.7
diff -u -r1.7 anycast.c --- linux-2.6/net/ipv6/anycast.c 25 Jul 2003 17:11:54 -0000 1.7
+++ linux-2.6/net/ipv6/anycast.c 6 Sep 2003 04:23:07 -0000 @@ -505,7 +505,7 @@
static void * ac6_seq_start ( struct seq_file * seq , loff_t * pos )
{
read_lock ( & dev_base_lock );
- return * pos ? ac6_get_idx ( seq , * pos ) : ac6_get_first ( seq );
+ return ac6_get_idx ( seq , * pos );
}
static void * ac6_seq_next ( struct seq_file * seq , void * v , loff_t * pos ) Index: linux-2.6/net/ipv6/mcast.c
===================================================================
RCS file: /home/cvs/linux-2.5/net/ipv6/mcast.c,v
retrieving revision 1.31
diff -u -r1.31 mcast.c --- linux-2.6/net/ipv6/mcast.c 1 Sep 2003 05:52:50 -0000 1.31
+++ linux-2.6/net/ipv6/mcast.c 6 Sep 2003 04:23:07 -0000 @@ -2119,7 +2119,7 @@
static void * igmp6_mc_seq_start ( struct seq_file * seq , loff_t * pos )
{
read_lock ( & dev_base_lock );
- return * pos ? igmp6_mc_get_idx ( seq , * pos ) : igmp6_mc_get_first ( seq );
+ return igmp6_mc_get_idx ( seq , * pos );
}
static void * igmp6_mc_seq_next ( struct seq_file * seq , void * v , loff_t * pos )
--
Hideaki YOSHIFUJI @ USAGI Project <yoshfuji@linux-ipv6.org>
GPG FP: 9022 65EB 1ECF 3AD1 0BDF 80D8 4807 F894 E062 0EEA
Hello.
In article [off-list ref] (at Sat, 06 Sep 2003 16:04:58 +0900 (JST)), YOSHIFUJI Hideaki / 吉藤英明 [off-list ref] says:
[1/3] /proc/net/{igmp,msfilter,raw,rt_cache,ip6_flowlabel,msfilter6,raw6} may drop some data : Note 0: These confilct with SEQ_START_TOKEN patches;
I'll regenerate if SEQ_START_TOKEN accepted.
Index: linux-2.6/net/ipv4/igmp.c
===================================================================
RCS file: /home/cvs/linux-2.5/net/ipv4/igmp.c,v
retrieving revision 1.35
diff -u -r1.35 igmp.c --- linux-2.6/net/ipv4/igmp.c 9 Sep 2003 23:24:51 -0000 1.35
+++ linux-2.6/net/ipv4/igmp.c 10 Sep 2003 01:00:49 -0000 @@ -2162,7 +2162,7 @@
static void * igmp_mc_seq_start ( struct seq_file * seq , loff_t * pos )
{
read_lock ( & dev_base_lock );
- return * pos ? igmp_mc_get_idx ( seq , * pos ) : SEQ_START_TOKEN ;
+ return * pos ? igmp_mc_get_idx ( seq , * pos - 1 ) : SEQ_START_TOKEN ;
}
static void * igmp_mc_seq_next ( struct seq_file * seq , void * v , loff_t * pos ) @@ -2337,7 +2337,7 @@
static void * igmp_mcf_seq_start ( struct seq_file * seq , loff_t * pos )
{
read_lock ( & dev_base_lock );
- return * pos ? igmp_mcf_get_idx ( seq , * pos ) : SEQ_START_TOKEN ;
+ return * pos ? igmp_mcf_get_idx ( seq , * pos - 1 ) : SEQ_START_TOKEN ;
}
static void * igmp_mcf_seq_next ( struct seq_file * seq , void * v , loff_t * pos ) Index: linux-2.6/net/ipv4/raw.c
===================================================================
RCS file: /home/cvs/linux-2.5/net/ipv4/raw.c,v
retrieving revision 1.36
diff -u -r1.36 raw.c --- linux-2.6/net/ipv4/raw.c 9 Sep 2003 23:24:51 -0000 1.36
+++ linux-2.6/net/ipv4/raw.c 10 Sep 2003 01:00:49 -0000 @@ -736,7 +736,7 @@
static void * raw_seq_start ( struct seq_file * seq , loff_t * pos )
{
read_lock ( & raw_v4_lock );
- return * pos ? raw_get_idx ( seq , * pos ) : SEQ_START_TOKEN ;
+ return * pos ? raw_get_idx ( seq , * pos - 1 ) : SEQ_START_TOKEN ;
}
static void * raw_seq_next ( struct seq_file * seq , void * v , loff_t * pos ) Index: linux-2.6/net/ipv4/route.c
===================================================================
RCS file: /home/cvs/linux-2.5/net/ipv4/route.c,v
retrieving revision 1.59
diff -u -r1.59 route.c --- linux-2.6/net/ipv4/route.c 9 Sep 2003 23:24:51 -0000 1.59
+++ linux-2.6/net/ipv4/route.c 10 Sep 2003 01:00:49 -0000 @@ -259,7 +259,7 @@
static void * rt_cache_seq_start ( struct seq_file * seq , loff_t * pos )
{
- return * pos ? rt_cache_get_idx ( seq , * pos ) : SEQ_START_TOKEN ;
+ return * pos ? rt_cache_get_idx ( seq , * pos - 1 ) : SEQ_START_TOKEN ;
}
static void * rt_cache_seq_next ( struct seq_file * seq , void * v , loff_t * pos ) Index: linux-2.6/net/ipv6/ip6_flowlabel.c
===================================================================
RCS file: /home/cvs/linux-2.5/net/ipv6/ip6_flowlabel.c,v
retrieving revision 1.9
diff -u -r1.9 ip6_flowlabel.c --- linux-2.6/net/ipv6/ip6_flowlabel.c 9 Sep 2003 23:24:51 -0000 1.9
+++ linux-2.6/net/ipv6/ip6_flowlabel.c 10 Sep 2003 01:00:49 -0000 @@ -603,7 +603,7 @@
static void * ip6fl_seq_start ( struct seq_file * seq , loff_t * pos )
{
read_lock_bh ( & ip6_fl_lock );
- return * pos ? ip6fl_get_idx ( seq , * pos ) : SEQ_START_TOKEN ;
+ return * pos ? ip6fl_get_idx ( seq , * pos - 1 ) : SEQ_START_TOKEN ;
}
static void * ip6fl_seq_next ( struct seq_file * seq , void * v , loff_t * pos ) Index: linux-2.6/net/ipv6/mcast.c
===================================================================
RCS file: /home/cvs/linux-2.5/net/ipv6/mcast.c,v
retrieving revision 1.32
diff -u -r1.32 mcast.c --- linux-2.6/net/ipv6/mcast.c 9 Sep 2003 23:24:51 -0000 1.32
+++ linux-2.6/net/ipv6/mcast.c 10 Sep 2003 01:00:49 -0000 @@ -2278,7 +2278,7 @@
static void * igmp6_mcf_seq_start ( struct seq_file * seq , loff_t * pos )
{
read_lock ( & dev_base_lock );
- return * pos ? igmp6_mcf_get_idx ( seq , * pos ) : SEQ_START_TOKEN ;
+ return * pos ? igmp6_mcf_get_idx ( seq , * pos - 1 ) : SEQ_START_TOKEN ;
}
static void * igmp6_mcf_seq_next ( struct seq_file * seq , void * v , loff_t * pos ) Index: linux-2.6/net/ipv6/raw.c
===================================================================
RCS file: /home/cvs/linux-2.5/net/ipv6/raw.c,v
retrieving revision 1.38
diff -u -r1.38 raw.c --- linux-2.6/net/ipv6/raw.c 9 Sep 2003 23:24:51 -0000 1.38
+++ linux-2.6/net/ipv6/raw.c 10 Sep 2003 01:00:49 -0000 @@ -961,7 +961,7 @@
static void * raw6_seq_start ( struct seq_file * seq , loff_t * pos )
{
read_lock ( & raw_v6_lock );
- return * pos ? raw6_get_idx ( seq , * pos ) : SEQ_START_TOKEN ;
+ return * pos ? raw6_get_idx ( seq , * pos - 1 ) : SEQ_START_TOKEN ;
}
static void * raw6_seq_next ( struct seq_file * seq , void * v , loff_t * pos )
--
Hideaki YOSHIFUJI @ USAGI Project <yoshfuji@linux-ipv6.org>
GPG FP: 9022 65EB 1ECF 3AD1 0BDF 80D8 4807 F894 E062 0EEA
Hello.
In article [off-list ref] (at Sat, 06 Sep 2003 16:04:58 +0900 (JST)), YOSHIFUJI Hideaki / 吉藤英明 [off-list ref] says:
[2/3] /proc/net/if_inet6 may drop some data : Note 0: These confilct with SEQ_START_TOKEN patches;
I'll regenerate if SEQ_START_TOKEN accepted.
Index: linux-2.6/net/ipv6/addrconf.c
===================================================================
RCS file: /home/cvs/linux-2.5/net/ipv6/addrconf.c,v
retrieving revision 1.53
diff -u -r1.53 addrconf.c --- linux-2.6/net/ipv6/addrconf.c 9 Sep 2003 23:24:51 -0000 1.53
+++ linux-2.6/net/ipv6/addrconf.c 10 Sep 2003 01:00:49 -0000 @@ -2149,59 +2149,65 @@
int bucket ;
};
- static inline struct inet6_ifaddr * if6_get_bucket ( struct seq_file * seq , loff_t * pos )
+ static struct inet6_ifaddr * if6_get_first ( struct seq_file * seq )
{
- int i ;
struct inet6_ifaddr * ifa = NULL ;
- loff_t l = * pos ;
struct if6_iter_state * state = seq -> private ;
- for (; state -> bucket < IN6_ADDR_HSIZE ; ++ state -> bucket )
- for ( i = 0 , ifa = inet6_addr_lst [ state -> bucket ]; ifa ; ++ i , ifa = ifa -> lst_next ) {
- if ( l -- )
- continue ;
- * pos = i ;
- goto out ;
- }
- out :
+ for ( state -> bucket = 0 ; state -> bucket < IN6_ADDR_HSIZE ; ++ state -> bucket ) {
+ ifa = inet6_addr_lst [ state -> bucket ];
+ if ( ifa )
+ break ;
+ }
+ return ifa ;
+ }
+
+ static struct inet6_ifaddr * if6_get_next ( struct seq_file * seq , struct inet6_ifaddr * ifa )
+ {
+ struct if6_iter_state * state = seq -> private ;
+
+ ifa = ifa -> lst_next ;
+ try_again :
+ if ( ! ifa && ++ state -> bucket < IN6_ADDR_HSIZE ) {
+ ifa = inet6_addr_lst [ state -> bucket ];
+ goto try_again ;
+ }
return ifa ;
}
+ static struct inet6_ifaddr * if6_get_idx ( struct seq_file * seq , loff_t pos )
+ {
+ struct inet6_ifaddr * ifa = if6_get_first ( seq );
+
+ if ( ifa )
+ while ( pos && ( ifa = if6_get_next ( seq , ifa )) != NULL )
+ -- pos ;
+ return pos ? NULL : ifa ;
+ }
+
static void * if6_seq_start ( struct seq_file * seq , loff_t * pos )
{
read_lock_bh ( & addrconf_hash_lock );
- return * pos ? if6_get_bucket ( seq , pos ) : SEQ_START_TOKEN ;
+ return if6_get_idx ( seq , * pos );
}
static void * if6_seq_next ( struct seq_file * seq , void * v , loff_t * pos )
{
struct inet6_ifaddr * ifa ;
- struct if6_iter_state * state ;
-
- if ( v == SEQ_START_TOKEN ) {
- ifa = if6_get_bucket ( seq , pos );
- goto out ;
- }
-
- state = seq -> private ;
-
- ifa = v ;
- ifa = ifa -> lst_next ;
- if ( ifa )
- goto out ;
-
- if ( ++ state -> bucket >= IN6_ADDR_HSIZE )
- goto out ;
- * pos = 0 ;
- ifa = if6_get_bucket ( seq , pos );
- out :
+ ifa = if6_get_next ( seq , v );
++* pos ;
return ifa ;
}
- static inline void if6_iface_seq_show ( struct seq_file * seq , struct inet6_ifaddr * ifp )
+ static void if6_seq_stop ( struct seq_file * seq , void * v )
+ {
+ read_unlock_bh ( & addrconf_hash_lock );
+ }
+
+ static int if6_seq_show ( struct seq_file * seq , void * v )
{
+ struct inet6_ifaddr * ifp = ( struct inet6_ifaddr * ) v ;
seq_printf ( seq ,
"%04x%04x%04x%04x%04x%04x%04x%04x %02x %02x %02x %02x %8s \n " ,
NIP6 ( ifp -> addr ), @@ -2210,20 +2216,7 @@
ifp -> scope ,
ifp -> flags ,
ifp -> idev -> dev -> name );
- }
-
- static int if6_seq_show ( struct seq_file * seq , void * v )
- {
- if ( v == SEQ_START_TOKEN )
- return 0 ;
- else
- if6_iface_seq_show ( seq , v );
return 0 ;
- }
-
- static void if6_seq_stop ( struct seq_file * seq , void * v )
- {
- read_unlock_bh ( & addrconf_hash_lock );
}
static struct seq_operations if6_seq_ops = {
--
Hideaki YOSHIFUJI @ USAGI Project <yoshfuji@linux-ipv6.org>
GPG FP: 9022 65EB 1ECF 3AD1 0BDF 80D8 4807 F894 E062 0EEA
Hello.
In article [off-list ref] (at Sat, 06 Sep 2003 16:04:58 +0900 (JST)), YOSHIFUJI Hideaki / 吉藤英明 [off-list ref] says:
In article [off-list ref] (at Thu, 4 Sep 2003 12:25:16 -0400 (EDT))
[3/3] clean up /proc/net/{anycast6,igmp6} : Note 0: These confilct with SEQ_START_TOKEN patches;
I'll regenerate if SEQ_START_TOKEN accepted.
Index: linux-2.6/net/ipv6/anycast.c
===================================================================
RCS file: /home/cvs/linux-2.5/net/ipv6/anycast.c,v
retrieving revision 1.7
diff -u -r1.7 anycast.c --- linux-2.6/net/ipv6/anycast.c 25 Jul 2003 17:11:54 -0000 1.7
+++ linux-2.6/net/ipv6/anycast.c 10 Sep 2003 01:00:49 -0000 @@ -505,7 +505,7 @@
static void * ac6_seq_start ( struct seq_file * seq , loff_t * pos )
{
read_lock ( & dev_base_lock );
- return * pos ? ac6_get_idx ( seq , * pos ) : ac6_get_first ( seq );
+ return ac6_get_idx ( seq , * pos );
}
static void * ac6_seq_next ( struct seq_file * seq , void * v , loff_t * pos ) Index: linux-2.6/net/ipv6/mcast.c
===================================================================
RCS file: /home/cvs/linux-2.5/net/ipv6/mcast.c,v
retrieving revision 1.32
diff -u -r1.32 mcast.c --- linux-2.6/net/ipv6/mcast.c 9 Sep 2003 23:24:51 -0000 1.32
+++ linux-2.6/net/ipv6/mcast.c 10 Sep 2003 01:00:49 -0000 @@ -2119,7 +2119,7 @@
static void * igmp6_mc_seq_start ( struct seq_file * seq , loff_t * pos )
{
read_lock ( & dev_base_lock );
- return * pos ? igmp6_mc_get_idx ( seq , * pos ) : igmp6_mc_get_first ( seq );
+ return igmp6_mc_get_idx ( seq , * pos );
}
static void * igmp6_mc_seq_next ( struct seq_file * seq , void * v , loff_t * pos )
--
Hideaki YOSHIFUJI @ USAGI Project <yoshfuji@linux-ipv6.org>
GPG FP: 9022 65EB 1ECF 3AD1 0BDF 80D8 4807 F894 E062 0EEA
Applied, thank you Yoshfuji.
Applied, thanks.
Applied, thanks.