On Mon, Jun 11, 2018 at 10:13:36AM +0200, Bastien Durel wrote:
> Because it's lower than RTP_CONNECTED and I don't know what it is. The
> /* local address routes (must be the highest) */ comment makes me think
> it MAY be 127.0.0.0/8 or ::1/128 (useless for rtadvd then), but it may
> be related to interface addresses; I did not check in the kernel code
> how this flag is set. (hence the question marks)
> 

RTP_LOCAL are local addresses, they won't pass the test at L367 of rtadvd.c
anyway.

Here is a diff if you want to try :

Index: if.c
===================================================================
RCS file: /cvs/src/usr.sbin/rtadvd/if.c,v
retrieving revision 1.46
diff -u -p -r1.46 if.c
--- if.c        12 Aug 2017 07:38:26 -0000      1.46
+++ if.c        17 Jun 2018 19:37:55 -0000
@@ -285,6 +285,14 @@ get_ifm_flags(char *buf)
        return (ifm->ifm_flags);
 }
 
+u_char
+get_priority(char *buf)
+{
+       struct rt_msghdr *rtm = (struct rt_msghdr *)buf;
+
+       return (rtm->rtm_priority);
+}
+
 int
 get_prefixlen(char *buf)
 {
Index: if.h
===================================================================
RCS file: /cvs/src/usr.sbin/rtadvd/if.h,v
retrieving revision 1.14
diff -u -p -r1.14 if.h
--- if.h        10 Aug 2017 19:07:14 -0000      1.14
+++ if.h        17 Jun 2018 19:37:55 -0000
@@ -45,6 +45,7 @@ struct in6_addr *get_addr(char *);
 int get_rtm_ifindex(char *);
 int get_ifm_ifindex(char *);
 int get_ifam_ifindex(char *);
+u_char get_priority(char *);
 int get_ifm_flags(char *);
 int get_prefixlen(char *);
 int prefixlen(u_char *, u_char *);
Index: rtadvd.c
===================================================================
RCS file: /cvs/src/usr.sbin/rtadvd/rtadvd.c,v
retrieving revision 1.91
diff -u -p -r1.91 rtadvd.c
--- rtadvd.c    22 Aug 2017 01:44:09 -0000      1.91
+++ rtadvd.c    17 Jun 2018 19:37:55 -0000
@@ -309,7 +309,7 @@ rtsock_cb(int fd, short event, void *arg
 {
        int n, type, ifindex = 0, oldifflags, plen;
        char *rtm;
-       u_char ifname[IF_NAMESIZE];
+       u_char ifname[IF_NAMESIZE], prio;
        struct prefix *prefix;
        struct rainfo *rai;
        struct in6_addr *addr;
@@ -362,6 +362,11 @@ rtsock_cb(int fd, short event, void *arg
 
                addr = get_addr(rtm);
                plen = get_prefixlen(rtm);
+               prio = get_priority(rtm);
+
+               if (!(prio & RTP_CONNECTED))
+                       break;
+
                /* sanity check for plen */
                /* as RFC2373, prefixlen is at least 4 */
                if (plen < 4 || plen > 127) {

Reply via email to