]> git.puffer.fish Git - mirror/frr.git/commitdiff
lib: Convert internal sequence number to int64_t 2139/head
authorDonald Sharp <sharpd@cumulusnetworks.com>
Sun, 29 Apr 2018 16:40:12 +0000 (12:40 -0400)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Sun, 29 Apr 2018 16:45:20 +0000 (12:45 -0400)
With the usage of a 32 bit number as a integer, but storing
non-signed values in it, we have cases where numbers greater
than 2 billion are being read in and stored and used before
lower value numbers, which of course is awful and mean.

Fixes: #2126
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
lib/plist.c
lib/plist_int.h

index 3d7127e0dae4ce78f1d03082bfa46641069f312e..e1dac46a90f823c2725c3527bdacaec7b3fd109a 100644 (file)
@@ -348,7 +348,7 @@ static void prefix_list_delete(struct prefix_list *plist)
 
 static struct prefix_list_entry *
 prefix_list_entry_make(struct prefix *prefix, enum prefix_list_type type,
-                      int seq, int le, int ge, int any)
+                      int64_t seq, int le, int ge, int any)
 {
        struct prefix_list_entry *pentry;
 
@@ -381,10 +381,10 @@ void prefix_list_delete_hook(void (*func)(struct prefix_list *plist))
 }
 
 /* Calculate new sequential number. */
-static int prefix_new_seq_get(struct prefix_list *plist)
+static int64_t prefix_new_seq_get(struct prefix_list *plist)
 {
-       int maxseq;
-       int newseq;
+       int64_t maxseq;
+       int64_t newseq;
        struct prefix_list_entry *pentry;
 
        maxseq = newseq = 0;
@@ -401,7 +401,7 @@ static int prefix_new_seq_get(struct prefix_list *plist)
 
 /* Return prefix list entry which has same seq number. */
 static struct prefix_list_entry *prefix_seq_check(struct prefix_list *plist,
-                                                 int seq)
+                                                 int64_t seq)
 {
        struct prefix_list_entry *pentry;
 
@@ -413,7 +413,8 @@ static struct prefix_list_entry *prefix_seq_check(struct prefix_list *plist,
 
 static struct prefix_list_entry *
 prefix_list_entry_lookup(struct prefix_list *plist, struct prefix *prefix,
-                        enum prefix_list_type type, int seq, int le, int ge)
+                        enum prefix_list_type type, int64_t seq,
+                        int le, int ge)
 {
        struct prefix_list_entry *pentry;
 
@@ -771,7 +772,7 @@ static void __attribute__((unused)) prefix_list_print(struct prefix_list *plist)
 
                        p = &pentry->prefix;
 
-                       printf("  seq %u %s %s/%d", pentry->seq,
+                       printf("  seq %" PRId64 " %s %s/%d", pentry->seq,
                               prefix_list_type_str(pentry),
                               inet_ntop(p->family, &p->u.prefix, buf, BUFSIZ),
                               p->prefixlen);
@@ -793,7 +794,7 @@ prefix_entry_dup_check(struct prefix_list *plist, struct prefix_list_entry *new)
        size_t validbits = new->prefix.prefixlen;
        struct pltrie_table *table;
        struct prefix_list_entry *pentry;
-       int seq = 0;
+       int64_t seq = 0;
 
        if (new->seq == -1)
                seq = prefix_new_seq_get(plist);
@@ -845,13 +846,13 @@ static int vty_prefix_list_install(struct vty *vty, afi_t afi, const char *name,
        struct prefix_list_entry *dup;
        struct prefix p, p_tmp;
        int any = 0;
-       int seqnum = -1;
+       int64_t seqnum = -1;
        int lenum = 0;
        int genum = 0;
 
        /* Sequential number. */
        if (seq)
-               seqnum = atoi(seq);
+               seqnum = (int64_t)atol(seq);
 
        /* ge and le number */
        if (ge)
@@ -972,7 +973,7 @@ static int vty_prefix_list_uninstall(struct vty *vty, afi_t afi,
        struct prefix_list *plist;
        struct prefix_list_entry *pentry;
        struct prefix p;
-       int seqnum = -1;
+       int64_t seqnum = -1;
        int lenum = 0;
        int genum = 0;
 
@@ -998,7 +999,7 @@ static int vty_prefix_list_uninstall(struct vty *vty, afi_t afi,
 
        /* Check sequence number. */
        if (seq)
-               seqnum = atoi(seq);
+               seqnum = (int64_t)atol(seq);
 
        /* ge and le number */
        if (ge)
@@ -1113,7 +1114,7 @@ static void vty_show_prefix_entry(struct vty *vty, afi_t afi,
                        vty_out(vty, "   Description: %s\n", plist->desc);
 
                vty_out(vty,
-                       "   count: %d, range entries: %d, sequences: %u - %u\n",
+                       "   count: %d, range entries: %d, sequences: %" PRId64 " - %" PRId64 "\n",
                        plist->count, plist->rangecount,
                        plist->head ? plist->head->seq : 0,
                        plist->tail ? plist->tail->seq : 0);
@@ -1128,7 +1129,7 @@ static void vty_show_prefix_entry(struct vty *vty, afi_t afi,
                        vty_out(vty, "   ");
 
                        if (master->seqnum)
-                               vty_out(vty, "seq %u ", pentry->seq);
+                               vty_out(vty, "seq %" PRId64 " ", pentry->seq);
 
                        vty_out(vty, "%s ", prefix_list_type_str(pentry));
 
@@ -1164,14 +1165,14 @@ static int vty_show_prefix_list(struct vty *vty, afi_t afi, const char *name,
 {
        struct prefix_list *plist;
        struct prefix_master *master;
-       int seqnum = 0;
+       int64_t seqnum = 0;
 
        master = prefix_master_get(afi, 0);
        if (master == NULL)
                return CMD_WARNING;
 
        if (seq)
-               seqnum = atoi(seq);
+               seqnum = (int64_t)atol(seq);
 
        if (name) {
                plist = prefix_list_lookup(afi, name);
@@ -1236,7 +1237,7 @@ static int vty_show_prefix_list_prefix(struct vty *vty, afi_t afi,
                }
 
                if (match) {
-                       vty_out(vty, "   seq %u %s ", pentry->seq,
+                       vty_out(vty, "   seq %" PRId64 " %s ", pentry->seq,
                                prefix_list_type_str(pentry));
 
                        if (pentry->any)
@@ -1744,7 +1745,7 @@ static int config_write_prefix_afi(afi_t afi, struct vty *vty)
                                afi == AFI_IP ? "" : "v6", plist->name);
 
                        if (master->seqnum)
-                               vty_out(vty, "seq %u ", pentry->seq);
+                               vty_out(vty, "seq %" PRId64 " ", pentry->seq);
 
                        vty_out(vty, "%s ", prefix_list_type_str(pentry));
 
@@ -1783,7 +1784,7 @@ static int config_write_prefix_afi(afi_t afi, struct vty *vty)
                                afi == AFI_IP ? "" : "v6", plist->name);
 
                        if (master->seqnum)
-                               vty_out(vty, "seq %u ", pentry->seq);
+                               vty_out(vty, "seq %" PRId64 " ", pentry->seq);
 
                        vty_out(vty, "%s", prefix_list_type_str(pentry));
 
@@ -1959,7 +1960,8 @@ int prefix_bgp_show_prefix_list(struct vty *vty, afi_t afi, char *name,
                        struct prefix *p = &pentry->prefix;
                        char buf[BUFSIZ];
 
-                       vty_out(vty, "   seq %u %s %s/%d", pentry->seq,
+                       vty_out(vty, "   seq %" PRId64 " %s %s/%d",
+                               pentry->seq,
                                prefix_list_type_str(pentry),
                                inet_ntop(p->family, &p->u.prefix, buf, BUFSIZ),
                                p->prefixlen);
index aa81a3bce220c1dbc46d39890efb324e07d64e38..6bc2d034d6996d21e65b16c9f9b1fe6bf34e14bc 100644 (file)
@@ -48,7 +48,7 @@ struct prefix_list {
 
 /* Each prefix-list's entry. */
 struct prefix_list_entry {
-       int seq;
+       int64_t seq;
 
        int le;
        int ge;