summaryrefslogtreecommitdiff
path: root/lib/jhash.c
diff options
context:
space:
mode:
authorBiswajit Sadhu <sadhub@vmware.com>2019-04-24 00:40:01 -0700
committerBiswajit Sadhu <sadhub@vmware.com>2019-04-24 00:40:01 -0700
commit2f6197b044edea555348f4c0c5acd2d3ab5feabf (patch)
tree5196e64b0eadccb8067f35327a0e8127fad250a4 /lib/jhash.c
parente400cd8aac83243ca47ae0797407a06b08d1dbb8 (diff)
bgpd: Prevent IPv6 routes received via a ibgp session with own ip as nexthop
Prevent IPv6 routes received via a ibgp session with one of its own interface ip as nexthop from getting installed in the BGP table. Implemented IPV6 HASH table, where we need to add any ipv6 address as they gets configured and delete them from the HASH table as the ipv6 addresses get unconfigured. The above hash table is used to verify if any route learned via BGP has nexthop which is equal to one of its its connected ipv6 interface. Signed-off-by: Biswajit Sadhu sadhub@vmware.com
Diffstat (limited to 'lib/jhash.c')
-rw-r--r--lib/jhash.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/jhash.c b/lib/jhash.c
index 0d561ef3a4..d0aff57d87 100644
--- a/lib/jhash.c
+++ b/lib/jhash.c
@@ -185,3 +185,18 @@ uint32_t jhash_1word(uint32_t a, uint32_t initval)
{
return jhash_3words(a, 0, 0, initval);
}
+
+/* ipv6 hash function */
+uint32_t __ipv6_addr_jhash(const struct in6_addr *a, const uint32_t initval)
+{
+ uint32_t v = 0;
+ uint32_t y[4] = {0};
+
+ /* Since s6_addr32 is not available is few os like FreeBSD, NetBDS,
+ * OMIBDS & OpenBDS. So recreating in uint32_t format.
+ */
+ memcpy(y, a->s6_addr, sizeof(struct in6_addr));
+ v = y[0] ^ y[1];
+
+ return jhash_3words(v, y[2], y[3], initval);
+}