Hello,
it's been a while since tags were introduced, but I have finally
managed to complete the patch to set realms from tags even it is a very
small patch.
The patch is attached, but can also be found at
https://github.com/KaloNK/quagga/commit/192a86ce7301d054d9f136f0cf4136978f8663c0
diff --git a/configure.ac b/configure.ac
index 2f77969..a63b63c 100755
--- a/configure.ac
+++ b/configure.ac
@@ -276,6 +276,8 @@ AC_ARG_ENABLE(configfile_mask,
AS_HELP_STRING([--enable-configfile-mask=ARG], [set mask for config files]))
AC_ARG_ENABLE(logfile_mask,
AS_HELP_STRING([--enable-logfile-mask=ARG], [set mask for log files]))
+AC_ARG_ENABLE(realms,
+ AS_HELP_STRING([--enable-realms], [enable REALMS support under Linux and convert tags to realms]))
AC_ARG_ENABLE(rtadv,
AS_HELP_STRING([--disable-rtadv], [disable IPV6 router advertisement feature]))
@@ -680,6 +682,18 @@ esac
AC_SYS_LARGEFILE
+dnl ------------------------
+dnl Enabled REALMS option
+dnl ------------------------
+if test "${enable_realms}" = "yes"; then
+ if test "${opsys}" != "gnu-linux"; then
+ echo "Sorry, only Linux has REALMS support"
+ exit 1
+ fi
+ AC_DEFINE(TAGS_TO_REALMS,, Realms support)
+fi
+AM_CONDITIONAL([TAGS_TO_REALMS], [test "${enable_realms}" = "yes"])
+
dnl ---------------------
dnl Integrated VTY option
dnl ---------------------
diff --git a/zebra/connected.c b/zebra/connected.c
index 1980007..da01d06 100644
--- a/zebra/connected.c
+++ b/zebra/connected.c
@@ -200,10 +200,10 @@ connected_up_ipv4 (struct interface *ifp, struct connected *ifc)
return;
rib_add_ipv4 (ZEBRA_ROUTE_CONNECT, 0, &p, NULL, NULL, ifp->ifindex,
- ifp->vrf_id, RT_TABLE_MAIN, ifp->metric, 0, 0, SAFI_UNICAST);
+ ifp->vrf_id, RT_TABLE_MAIN, ifp->metric, 0, 0, 0, SAFI_UNICAST);
rib_add_ipv4 (ZEBRA_ROUTE_CONNECT, 0, &p, NULL, NULL, ifp->ifindex,
- ifp->vrf_id, RT_TABLE_MAIN, ifp->metric, 0, 0, SAFI_MULTICAST);
+ ifp->vrf_id, RT_TABLE_MAIN, ifp->metric, 0, 0, 0, SAFI_MULTICAST);
rib_update (ifp->vrf_id);
}
diff --git a/zebra/kernel_socket.c b/zebra/kernel_socket.c
index 64c6cbb..262f4bb 100644
--- a/zebra/kernel_socket.c
+++ b/zebra/kernel_socket.c
@@ -1008,7 +1008,7 @@ rtm_read (struct rt_msghdr *rtm)
|| rtm->rtm_type == RTM_ADD
|| rtm->rtm_type == RTM_CHANGE)
rib_add_ipv4 (ZEBRA_ROUTE_KERNEL, zebra_flags, &p, &gate.sin.sin_addr,
- NULL, 0, VRF_DEFAULT, 0, 0, 0, 0, SAFI_UNICAST);
+ NULL, 0, VRF_DEFAULT, 0, 0, 0, 0, 0, SAFI_UNICAST);
else
rib_delete_ipv4 (ZEBRA_ROUTE_KERNEL, zebra_flags, &p,
&gate.sin.sin_addr, 0, VRF_DEFAULT, SAFI_UNICAST);
diff --git a/zebra/rib.h b/zebra/rib.h
index 0191f57..e98f29c 100644
--- a/zebra/rib.h
+++ b/zebra/rib.h
@@ -424,7 +424,7 @@ extern struct route_table *zebra_vrf_static_table (afi_t, safi_t, vrf_id_t);
extern int rib_add_ipv4 (int type, int flags, struct prefix_ipv4 *p,
struct in_addr *gate, struct in_addr *src,
ifindex_t ifindex, vrf_id_t vrf_id, int table_id,
- u_int32_t, u_int32_t, u_char, safi_t);
+ u_int32_t, u_int32_t, u_char, route_tag_t, safi_t);
extern int rib_add_ipv4_multipath (struct prefix_ipv4 *, struct rib *, safi_t);
diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c
index 1a91426..8817724 100644
--- a/zebra/rt_netlink.c
+++ b/zebra/rt_netlink.c
@@ -732,6 +732,7 @@ netlink_routing_table (struct sockaddr_nl *snl, struct nlmsghdr *h,
int index;
int table;
u_int32_t mtu = 0;
+ route_tag_t tag = 0;
void *dest;
void *gate;
@@ -790,6 +791,11 @@ netlink_routing_table (struct sockaddr_nl *snl, struct nlmsghdr *h,
if (tb[RTA_GATEWAY])
gate = RTA_DATA (tb[RTA_GATEWAY]);
+#ifdef TAGS_TO_REALMS
+ if (tb[RTA_FLOW])
+ tag = *(u_int32_t *) RTA_DATA (tb[RTA_FLOW]);
+#endif
+
if (tb[RTA_METRICS])
{
struct rtattr *mxrta[RTAX_MAX+1];
@@ -811,7 +817,7 @@ netlink_routing_table (struct sockaddr_nl *snl, struct nlmsghdr *h,
if (!tb[RTA_MULTIPATH])
rib_add_ipv4 (ZEBRA_ROUTE_KERNEL, flags, &p, gate, src, index,
- vrf_id, table, 0, mtu, 0, SAFI_UNICAST);
+ vrf_id, table, 0, mtu, 0, 0, SAFI_UNICAST);
else
{
/* This is a multipath route */
@@ -828,6 +834,7 @@ netlink_routing_table (struct sockaddr_nl *snl, struct nlmsghdr *h,
rib->flags = flags;
rib->metric = 0;
rib->mtu = mtu;
+ rib->tag = tag;
rib->vrf_id = vrf_id;
rib->table = table;
rib->nexthop_num = 0;
@@ -839,6 +846,13 @@ netlink_routing_table (struct sockaddr_nl *snl, struct nlmsghdr *h,
break;
index = rtnh->rtnh_ifindex;
+
+#ifdef TAGS_TO_REALMS
+ rib->tag = 0;
+ if (tb[RTA_FLOW])
+ rib->tag = *(u_int32_t *) RTA_DATA (tb[RTA_FLOW]);
+#endif
+
gate = 0;
if (rtnh->rtnh_len > sizeof (*rtnh))
{
@@ -915,6 +929,7 @@ netlink_route_change (struct sockaddr_nl *snl, struct nlmsghdr *h,
int index;
int table;
u_int32_t mtu = 0;
+ route_tag_t tag = 0;
void *dest;
void *gate;
@@ -991,6 +1006,11 @@ netlink_route_change (struct sockaddr_nl *snl, struct nlmsghdr *h,
if (tb[RTA_GATEWAY])
gate = RTA_DATA (tb[RTA_GATEWAY]);
+#ifdef TAGS_TO_REALMS
+ if (tb[RTA_FLOW])
+ tag = *(u_int32_t *) RTA_DATA (tb[RTA_FLOW]);
+#endif
+
if (tb[RTA_PREFSRC])
src = RTA_DATA (tb[RTA_PREFSRC]);
@@ -1028,7 +1048,7 @@ netlink_route_change (struct sockaddr_nl *snl, struct nlmsghdr *h,
{
if (!tb[RTA_MULTIPATH])
rib_add_ipv4 (ZEBRA_ROUTE_KERNEL, 0, &p, gate, src, index, vrf_id,
- table, 0, mtu, 0, SAFI_UNICAST);
+ table, 0, mtu, 0, 0, SAFI_UNICAST);
else
{
/* This is a multipath route */
@@ -1045,6 +1065,7 @@ netlink_route_change (struct sockaddr_nl *snl, struct nlmsghdr *h,
rib->flags = 0;
rib->metric = 0;
rib->mtu = mtu;
+ rib->tag = tag;
rib->vrf_id = vrf_id;
rib->table = table;
rib->nexthop_num = 0;
@@ -1056,6 +1077,13 @@ netlink_route_change (struct sockaddr_nl *snl, struct nlmsghdr *h,
break;
index = rtnh->rtnh_ifindex;
+
+#ifdef TAGS_TO_REALMS
+ rib->tag = 0;
+ if (tb[RTA_FLOW])
+ rib->tag = *(u_int32_t *) RTA_DATA (tb[RTA_FLOW]);
+#endif
+
gate = 0;
if (rtnh->rtnh_len > sizeof (*rtnh))
{
@@ -1723,6 +1751,10 @@ netlink_route_multipath (int cmd, struct prefix *p, struct rib *rib)
/* Metric. */
addattr32 (&req.n, sizeof req, RTA_PRIORITY, NL_DEFAULT_ROUTE_METRIC);
+#ifdef TAGS_TO_REALMS
+ addattr32 (&req.n, sizeof req, RTA_FLOW, rib->tag);
+#endif
+
if (rib->mtu || rib->nexthop_mtu)
{
char buf[NL_PKT_BUF_SIZE];
diff --git a/zebra/rtread_getmsg.c b/zebra/rtread_getmsg.c
index e1ec670..988231d 100644
--- a/zebra/rtread_getmsg.c
+++ b/zebra/rtread_getmsg.c
@@ -93,7 +93,7 @@ handle_route_entry (mib2_ipRouteEntry_t *routeEntry)
rib_add_ipv4 (ZEBRA_ROUTE_KERNEL, zebra_flags, &prefix,
&gateway, NULL, 0, VRF_DEFAULT, RT_TABLE_MAIN,
- 0, 0, 0, SAFI_UNICAST);
+ 0, 0, 0, 0, SAFI_UNICAST);
}
void
diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c
index abb9560..3e4bccf 100644
--- a/zebra/zebra_rib.c
+++ b/zebra/zebra_rib.c
@@ -1691,7 +1691,7 @@ int
rib_add_ipv4 (int type, int flags, struct prefix_ipv4 *p,
struct in_addr *gate, struct in_addr *src,
ifindex_t ifindex, vrf_id_t vrf_id, int table_id,
- u_int32_t metric, u_int32_t mtu, u_char distance, safi_t safi)
+ u_int32_t metric, u_int32_t mtu, u_char distance, route_tag_t tag, safi_t safi)
{
struct rib *rib;
struct rib *same = NULL;
@@ -1755,6 +1755,7 @@ rib_add_ipv4 (int type, int flags, struct prefix_ipv4 *p,
rib->flags = flags;
rib->metric = metric;
rib->mtu = mtu;
+ rib->tag = tag;
rib->vrf_id = vrf_id;
rib->table = table_id;
rib->nexthop_num = 0;
_______________________________________________
Quagga-dev mailing list
[email protected]
https://lists.quagga.net/mailman/listinfo/quagga-dev