That looks ok to me. Presumably you've tested that the counter returns to zero when the routers go away; that's a little tricky to code review in a few minutes. I think it would be good to add a stat that counts RAs/prefixes (something) that are rejected due to the count. Whenever I have trouble I do "netstat -s" befoer and after trying something and diff them, to find the counter that I didn't expect to change but does. If this code ever gets in a bad state as it is we'll get silent failure to accept RAs.
Attachment:
pgp3oie64scEE.pgp
Description: PGP signature