User Tools

Site Tools


Differences

This shows you the differences between two versions of the page.

Link to this comparison view

bird [2019-06-21 14:14] (current)
Line 1: Line 1:
 +~~NOTOC~~
  
 +
 +======Bird patch for FreeBSD 11======
 +
 +
 +
 +
 +Also I wrote [[https://​bugs.freebsd.org/​bugzilla/​show_bug.cgi?​id=211717|problem report 211717]].
 +
 +====Symptom====
 +
 +  * In log
 +
 +<​code>​
 +2016-08-07 02:28:55 <ERR> KRT: Error sending route 10.120.1.98/​32 to kernel: Address family not supported by protocol family
 +</​code>​
 +
 +  * In //route monitor//
 +
 +<​code>​
 +got message of size 128 on Sun Aug  7 19:52:27 2016
 +RTM_ADD: Add Route: len 128, pid: 3683, seq 312, errno 22, flags:<​UP,​GATEWAY,​HOST,​PROTO1>​
 +locks: ​ inits: ​
 +sockaddrs: <​DST,​GATEWAY>​
 +
 +pmsg_addrs: truncated route message, only 36 bytes left
 +</​code>​
 +
 +
 +====Cause====
 +
 +Incorrect packing of route message to kernel.
 +
 +====Draft patch====
 +
 +<code | bird.patch>​
 +--- ./​sysdep/​bsd/​krt-sock.c.orig ​       2016-04-29 11:​13:​23.000000000 +0200
 ++++ ./​sysdep/​bsd/​krt-sock.c ​    ​2016-08-08 00:​12:​32.516209000 +0200
 +@@ -167,13 +167,14 @@
 + ​struct ks_msg
 + {
 +   ​struct rt_msghdr rtm;
 +-  struct sockaddr_storage buf[RTAX_MAX];​
 ++  struct ​ sockaddr_in buf[RTAX_MAX];​
 + };
 + 
 + #​define ROUNDUP(a) \
 +         ((a) > 0 ? (1 + (((a) - 1) | (sizeof(long) - 1))) : sizeof(long))
 + 
 +-#define NEXTADDR(w, u) \
 ++#define __NEXTADDR(w,​ u) \
 +         if (msg.rtm.rtm_addrs & (w)) {\
 +           l = ROUNDUP(((struct sockaddr *)&​(u))->​sa_len);​\
 +           ​memmove(body,​ &(u), l); body += l;}
 +@@ -185,6 +186,17 @@
 +     ​memcpy(p,​ body, (l > sizeof(*p) ? sizeof(*p) : l));\
 +     body += l;}
 + 
 ++
 ++#define NEXTADDR(w, u)                                                 \
 ++       if (msg.rtm.rtm_addrs & (w)) {                                          \
 ++               l = (((struct sockaddr *)&​(u))->​sa_len == 0) ?          \
 ++                   ​sizeof(long) :                                      \
 ++                   1 + ((((struct sockaddr *)&​(u))->​sa_len - 1)        \
 ++                       | (sizeof(long) - 1));                          \
 ++               ​memmove(body,​ &(u), l); body += l;                              \
 ++       }
 ++
 ++
 + ​static int
 + ​krt_send_route(struct krt_proto *p, int cmd, rte *e)
 + {
 +
 +</​code>​
 +
 +====Checking====
 +
 +<​code>​
 +
 +# route -nv monitor
 +...
 +got message of size 140 on Sun Aug  7 16:57:43 2016
 +RTM_ADD: Add Route: len 140, pid: 8102, seq 82, errno 0, flags:<​UP,​GATEWAY,​DONE,​PROTO1>​
 +locks: ​ inits: ​
 +sockaddrs: <​DST,​GATEWAY,​NETMASK>​
 + ​10.255.252.172 192.168.58.1 255.255.255.252
 +
 +got message of size 124 on Sun Aug  7 16:57:43 2016
 +RTM_ADD: Add Route: len 124, pid: 8102, seq 83, errno 0, flags:<​UP,​GATEWAY,​HOST,​DONE,​PROTO1>​
 +locks: ​ inits: ​
 +sockaddrs: <​DST,​GATEWAY>​
 + ​10.120.65.4 192.168.58.1
 +
 +</​code>​
 +
 +===BIRD routing diagram===
 +
 +{{ ::​bird-route.png?​640 |}}
 +
 +----
 +[<>]