]> git.puffer.fish Git - mirror/frr.git/commitdiff
sharpd: Fix nexthop group name collision 7336/head
authorDonald Sharp <sharpd@nvidia.com>
Sat, 17 Oct 2020 01:44:29 +0000 (21:44 -0400)
committerDonald Sharp <sharpd@nvidia.com>
Sat, 17 Oct 2020 01:44:29 +0000 (21:44 -0400)
If you have two nexthop groups named
one
oneone

then the sharp daemon will treat them as the same nexthop
group.  This is because we are doign this:

static int sharp_nhg_compare_func(const struct sharp_nhg *a,
                                  const struct sharp_nhg *b)
{
        return strncmp(a->name, b->name, strlen(a->name));
}

The strlen should be the size of the array of name.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
sharpd/sharp_nht.c

index 7484dd3b068837f29ebeaf83b9007a7be709f6b0..077e2b29eb4ac39c3e3fd389a766fdbf572c6692 100644 (file)
@@ -77,7 +77,8 @@ struct sharp_nhg {
 
        uint32_t id;
 
-       char name[256];
+#define NHG_NAME_LEN 256
+       char name[NHG_NAME_LEN];
 
        bool installed;
 };
@@ -95,7 +96,7 @@ struct sharp_nhg_rb_head nhg_head;
 static int sharp_nhg_compare_func(const struct sharp_nhg *a,
                                  const struct sharp_nhg *b)
 {
-       return strncmp(a->name, b->name, strlen(a->name));
+       return strncmp(a->name, b->name, NHG_NAME_LEN);
 }
 
 DECLARE_RBTREE_UNIQ(sharp_nhg_rb, struct sharp_nhg, mylistitem,