[PATCH 1/4] Core changes to support SADR

Ondrej Zajicek santiago at crfreenet.org
Tue May 23 15:12:48 CEST 2017


On Sun, May 21, 2017 at 11:01:34PM +0200, Dean Luga wrote:
> @@ -1394,7 +1404,8 @@ nl_parse_route(struct nl_parse_state *s, struct nlmsghdr *h)
>    struct rtattr *a[BIRD_RTA_MAX];
>    int new = h->nlmsg_type == RTM_NEWROUTE;
>  
> -  net_addr dst;
> +  net_addr dst, sadr_src;
> +  net_fill_ip6(&sadr_src, IP6_NONE, 0);
>    u32 oif = ~0;
>    u32 table_id;
>    u32 priority = 0;
> @@ -1420,6 +1431,9 @@ nl_parse_route(struct nl_parse_state *s, struct nlmsghdr *h)
>        if (!nl_parse_attrs(RTM_RTA(i), rtm_attr_want6, a, sizeof(a)))
>  	return;
>  
> +      if (a[RTA_SRC])
> +	net_fill_ip6(&sadr_src, rta_get_ip6(a[RTA_SRC]), i->rtm_src_len);
> +
>        if (a[RTA_DST])
>  	net_fill_ip6(&dst, rta_get_ip6(a[RTA_DST]), i->rtm_dst_len);
>        else
> @@ -1496,7 +1510,15 @@ nl_parse_route(struct nl_parse_state *s, struct nlmsghdr *h)
>        src = KRT_SRC_ALIEN;
>      }
>  
> -  net *net = net_get(p->p.main_channel->table, &dst);
> +  net *net;
> +  if (p->p.main_channel->table->addr_type == NET_SADR_IP6)
> +  {
> +    net_addr_sadr_ip6 sadr_addr =
> +      NET_ADDR_SADR_IP6(net_prefix(&dst), net_pxlen(&dst), net_prefix(&sadr_src), net_pxlen(&sadr_src));
> +    net = net_get(p->p.main_channel->table, (net_addr *)&sadr_addr);
> +  }
> +  else
> +    net = net_get(p->p.main_channel->table, &dst);

IMHO there should be check that if the found protocol is not SADR, then routes with
RTA_SRC other than ::/0 should be ignored, in the same way like routes with IIF or
ToS are ignored:

  if (a[RTA_IIF])
    SKIP("IIF set\n");

  if (i->rtm_tos != 0)                  /* We don't support TOS */
    SKIP("TOS %02x\n", i->rtm_tos);

-- 
Elen sila lumenn' omentielvo

Ondrej 'Santiago' Zajicek (email: santiago at crfreenet.org)
OpenPGP encrypted e-mails preferred (KeyID 0x11DEADC3, wwwkeys.pgp.net)
"To err is human -- to blame it on a computer is even more so."



More information about the Bird-users mailing list