Skip to contentSkip to conversation

ipv6: Do not depend on rt->n in rt6_probe().

DISCUSSION Dan Carpenter 3 participants 6 messages Jan 21, 2013 – Jan 22, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hello YOSHIFUJI Hideaki / 吉藤英明,

This is a semi-automatic email about new static checker warnings.

The patch 2152caea7196: "ipv6: Do not depend on rt->n in rt6_probe()." from Jan 17, 2013, leads to the following Smatch complaint:

net/ipv6/route.c:495 rt6_probe()
error: we previously assumed 'neigh' could be null (see line 490)

net/ipv6/route.c
489
490 if (!neigh ||

                     ^^^^^

New test.

491 time_after(jiffies, neigh->updated + rt->rt6i_idev->cnf.rtr_probe_interval)) {
492 struct in6_addr mcaddr;
493 struct in6_addr *target;
494

   495			neigh->updated = jiffies;
                        ^^^^^^^^^^^^^^

Old dereference.

496
497 if (neigh)

                            ^^^^^

Another new test.

regards,
dan carpenter

#1 lore raw
Quoted 23 lines · Dan Carpenter

Hello YOSHIFUJI Hideaki / 吉藤英明,

This is a semi-automatic email about new static checker warnings.

The patch 2152caea7196: "ipv6: Do not depend on rt->n in rt6_probe()." from Jan 17, 2013, leads to the following Smatch complaint:

net/ipv6/route.c:495 rt6_probe()
error: we previously assumed 'neigh' could be null (see line 490)

net/ipv6/route.c
489
490 if (!neigh ||

                     ^^^^^

New test.

   491		    time_after(jiffies, neigh->updated + rt->rt6i_idev->cnf.rtr_probe_interval)) {
   492			struct in6_addr mcaddr;
   493			struct in6_addr *target;
   494	
   495			neigh->updated = jiffies;
                        ^^^^^^^^^^^^^^
Quoted 6 lines

Old dereference.

   496	
   497			if (neigh)
                            ^^^^^

Another new test.

Oh, right, I'll fix. Thanks!

--yoshfuji

#2 lore raw

Rate Limitation of Router Reachability Probing for possible dead routers (is Re: ipv6: Do not depend on rt->n in rt6_probe().)

Quoted 26 lines · YOSHIFUJI Hideaki
Quoted 25 lines · Dan Carpenter

Hello YOSHIFUJI Hideaki / 吉藤英明,

This is a semi-automatic email about new static checker warnings.

The patch 2152caea7196: "ipv6: Do not depend on rt->n in rt6_probe()." from Jan 17, 2013, leads to the following Smatch complaint:

net/ipv6/route.c:495 rt6_probe()
error: we previously assumed 'neigh' could be null (see line 490)

net/ipv6/route.c
489
490 if (!neigh ||

                     ^^^^^

New test.

   491		    time_after(jiffies, neigh->updated + rt->rt6i_idev->cnf.rtr_probe_interval)) {
   492			struct in6_addr mcaddr;
   493			struct in6_addr *target;
   494	
   495			neigh->updated = jiffies;
                        ^^^^^^^^^^^^^^

Old dereference.

Quoted 6 lines
Quoted 4 lines
   496	
   497			if (neigh)
                            ^^^^^

Another new test.

Oh, right, I'll fix. Thanks!

Ok, fix is easy, but in fact, we have broken router reachability probing.

Here rt->n was neighbour entry for (unreachable) router. The specification says, we SHOUDLD probe such router, but we should have some rate limit (once per minute, or so).

We used "rt->n->updated" for this purpose, but now, if NS failed, we may immediately removes neighbour entry for it. So, we might continue sending NS to dead router every 1 second.

Any ideas?

--yoshfuji

maintainer
#3 lore raw

Re: Rate Limitation of Router Reachability Probing for possible dead routers (is Re: ipv6: Do not depend on rt->n in rt6_probe().)

From: YOSHIFUJI Hideaki <[email protected]>
Date: Tue, 22 Jan 2013 04:28:36 +0900

Quoted 7 lines

Ok, fix is easy, but in fact, we have broken router reachability probing.

Here rt->n was neighbour entry for (unreachable) router. The specification says, we SHOUDLD probe such router, but we should have some rate limit (once per minute, or so).

Quoted 5 lines

We used "rt->n->updated" for this purpose, but now, if NS failed, we may immediately removes neighbour entry for it. So, we might continue sending NS to dead router every 1 second.

Any ideas?

I don't see exactly how looking up the neigh on demand is different from using a cached one in this context.

In both cases there should be a neigh entry in nd_tbl, why would there not be one?

If necessary, you can decide to mark entries in such a way that they would have a lower priority for neigh GC purging if that is the issue.

#4 lore raw

Re: Rate Limitation of Router Reachability Probing for possible dead routers (is Re: ipv6: Do not depend on rt->n in rt6_probe().)

Quoted 14 lines · David Miller

From: YOSHIFUJI Hideaki <[email protected]>
Date: Tue, 22 Jan 2013 04:28:36 +0900

Quoted 11 lines

Ok, fix is easy, but in fact, we have broken router reachability probing.

Here rt->n was neighbour entry for (unreachable) router. The specification says, we SHOUDLD probe such router, but we should have some rate limit (once per minute, or so).

We used "rt->n->updated" for this purpose, but now, if NS failed, we may immediately removes neighbour entry for it. So, we might continue sending NS to dead router every 1 second.

Quoted 7 lines
Quoted 1 line

Any ideas?

I don't see exactly how looking up the neigh on demand is different from using a cached one in this context.

In both cases there should be a neigh entry in nd_tbl, why would there not be one?

Well, now, the almost only refcnt holder except table is timer. because each route does not have reference to neighbour (thus no refcnt) anymore.

If n->nud_state become NUD_FAILED (or even in NUD_STALE), the entry does not have any refcnt holders other than table, and then, neigh_periodic_work() will purge such entries.

Quoted 3 lines

If necessary, you can decide to mark entries in such a way that they would have a lower priority for neigh GC purging if that is the issue.

It seems that we removed check for gc_thresh1 (number of minimum entries) in neigh_alloc() during 2.3.x but I cannot remember the reason (or just I do not know it).

--yoshfuji

maintainer
#5 lore raw

Re: Rate Limitation of Router Reachability Probing for possible dead routers (is Re: ipv6: Do not depend on rt->n in rt6_probe().)

From: YOSHIFUJI Hideaki <[email protected]>
Date: Tue, 22 Jan 2013 12:47:42 +0900

Quoted 3 lines

It seems that we removed check for gc_thresh1 (number of minimum entries) in neigh_alloc() during 2.3.x but I cannot remember the reason (or just I do not know it).

You seem to suggest that neigh_periodic_work() should check gc_thresh1 and I agree with this idea.

Considering how neighbour references work now, what it does currently doesn't make any sense.

Right now it runs over and over again, unconditionally, and purges entries even if there are very few of them.