Hello Anthony,

> Currently, I'm using a dummy interface and adding the IPs they own as
> v4 /32 and v6 /128 and in combination with an export filter to only
> export /32 and /128 prefixes, this works great.
> 
> However, I was wondering if there is a way to configure BIRD so that
> for the IPs configured on the host it supplants the configured prefix
> with /32 and/or /128 allowing me to eliminate the dummy interface?

I think this would be quite an easy extension to the Direct protocol,
something like the attached patch, adding the `self` option to it.

Disclaimer: This patch is atop `master` (which I happened to have
checked out) and not much tested, just fastcoded, completely
undocumented, and definitely not stable.

Maria

-- 
Maria Matejka (she/her) | BIRD Team Leader | CZ.NIC, z.s.p.o.
diff --git a/nest/config.Y b/nest/config.Y
index 4a3b45b50..e3e766b34 100644
--- a/nest/config.Y
+++ b/nest/config.Y
@@ -479,6 +479,7 @@ dev_proto:
  | dev_proto proto_channel ';'
  | dev_proto dev_iface_patt ';'
  | dev_proto CHECK LINK bool ';' { DIRECT_CFG->check_link = $4; }
+ | dev_proto SELF bool ';' { DIRECT_CFG->host = $3; }
  ;
 
 dev_iface_init:
diff --git a/nest/rt-dev.c b/nest/rt-dev.c
index 7932b8b7d..6ea18d020 100644
--- a/nest/rt-dev.c
+++ b/nest/rt-dev.c
@@ -32,6 +32,7 @@ dev_ifa_notify(struct proto *P, uint flags, struct ifa *ad)
   struct rt_dev_config *cf = (void *) P->cf;
   struct channel *c;
   net_addr *net = &ad->prefix;
+  net_addr_union nau;
 
   if (!EMPTY_LIST(cf->iface_list) &&
       !iface_patt_find(&cf->iface_list, ad->iface, ad))
@@ -45,9 +46,23 @@ dev_ifa_notify(struct proto *P, uint flags, struct ifa *ad)
     return;
 
   if (ad->prefix.type == NET_IP4)
+  {
     c = p->ip4_channel;
+    if (cf->host)
+    {
+      nau.ip4 = NET_ADDR_IP4(ipa_to_ip4(ad->ip), 32);
+      net = &nau.n;
+    }
+  }
   else if (ad->prefix.type == NET_IP6)
+  {
     c = p->ip6_channel;
+    if (cf->host)
+    {
+      nau.ip6 = NET_ADDR_IP6(ipa_to_ip6(ad->ip), 128);
+      net = &nau.n;
+    }
+  }
   else
     return;
 
@@ -155,6 +170,7 @@ dev_reconfigure(struct proto *P, struct proto_config *CF)
   struct rt_dev_config *n = (void *) CF;
 
   if (!iface_patts_equal(&o->iface_list, &n->iface_list, NULL) ||
+      (o->host != n->host) ||
       (o->check_link != n->check_link))
     return 0;
 
@@ -179,6 +195,7 @@ dev_copy_config(struct proto_config *dest, struct proto_config *src)
   cfg_copy_list(&d->iface_list, &s->iface_list, sizeof(struct iface_patt));
 
   d->check_link = s->check_link;
+  d->host = s->host;
 }
 
 struct protocol proto_device = {
diff --git a/nest/rt-dev.h b/nest/rt-dev.h
index 5d91242a1..4ea3b367c 100644
--- a/nest/rt-dev.h
+++ b/nest/rt-dev.h
@@ -13,6 +13,7 @@ struct rt_dev_config {
   struct proto_config c;
   list iface_list;		/* list of struct iface_patt */
   int check_link;
+  int host;
 
   struct channel_config *ip4_channel;
   struct channel_config *ip6_channel;

Reply via email to