summaryrefslogtreecommitdiffstats
path: root/lib/sockunion.c
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@cumulusnetworks.com>2015-06-12 16:59:11 +0200
committerDonald Sharp <sharpd@cumulusnetworks.com>2015-06-12 16:59:11 +0200
commited40466af80c9d0b88436c637a1d54b28a669b1c (patch)
treeb092d22e9591da81776a56006dc2883f445b0ddd /lib/sockunion.c
parentThis patch changes BGP from only listening mode for BFD status updates to int... (diff)
downloadfrr-ed40466af80c9d0b88436c637a1d54b28a669b1c.tar.xz
frr-ed40466af80c9d0b88436c637a1d54b28a669b1c.zip
bgpd-set-somark.patch
BGP: Set SO_MARK on connecting sockets to ensure lookup in right routing table In the presence of a function such as management VRF/MRF, bgpd needs to be able to specify that it intends to run in the dataplane and not the front panel. To ensure this, we add a mark in the connecting socket so that the kernel does the routing lookup in the right table. This assumes that an appropriate ip rule has been configured (outside the scope of this package). While we've forced the mark to be 254 for now, it maybe required to make it configurable at a later time.
Diffstat (limited to 'lib/sockunion.c')
-rw-r--r--lib/sockunion.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/sockunion.c b/lib/sockunion.c
index efd41362c..59c5ba5dd 100644
--- a/lib/sockunion.c
+++ b/lib/sockunion.c
@@ -496,6 +496,25 @@ sockopt_cork (int sock, int onoff)
#endif
}
+int sockopt_mark_default(int sock, int mark, struct zebra_privs_t *cap)
+{
+#ifdef SO_MARK
+ int ret;
+
+ if ( cap->change (ZPRIVS_RAISE) )
+ zlog_err ("routing_socket: Can't raise privileges");
+
+ ret = setsockopt(sock, SOL_SOCKET, SO_MARK, &mark, sizeof(mark));
+
+ if ( cap->change (ZPRIVS_LOWER) )
+ zlog_err ("routing_socket: Can't lower privileges");
+
+ return ret;
+#else
+ return 0;
+#endif
+}
+
int
sockopt_minttl (int family, int sock, int minttl)
{