]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Minor cleanups and fixes
authorOndrej Zajicek (work) <santiago@crfreenet.org>
Tue, 23 May 2017 11:12:25 +0000 (13:12 +0200)
committerOndrej Zajicek (work) <santiago@crfreenet.org>
Tue, 23 May 2017 11:12:25 +0000 (13:12 +0200)
conf/flowspec.Y
lib/flowspec.c
lib/flowspec.h
nest/proto.c
proto/bfd/packets.c
proto/rip/packets.c
proto/rip/rip.c
sysdep/linux/netlink.c
sysdep/unix/io.c

index a47d453b790d61b8822ab079d1f7d4b1c0b188df..8c72854ca004d2e1ad759314eb4abfb77bf9d32d 100644 (file)
@@ -44,19 +44,19 @@ CF_GRAMMAR
 /* Network Flow Specification */
 
 flow_num_op:
-   TRUE                { $$ = 0b000; }
- | '='         { $$ = 0b001; }
- | NEQ         { $$ = 0b110; }
- | '<'         { $$ = 0b100; }
- | LEQ         { $$ = 0b101; }
- | '>'         { $$ = 0b010; }
- | GEQ         { $$ = 0b011; }
- | FALSE       { $$ = 0b111; }
+   TRUE                { $$ = FLOW_OP_TRUE; }
+ | '='         { $$ = FLOW_OP_EQ;  }
+ | NEQ         { $$ = FLOW_OP_NEQ; }
+ | '<'         { $$ = FLOW_OP_LT;  }
+ | LEQ         { $$ = FLOW_OP_LEQ; }
+ | '>'         { $$ = FLOW_OP_GT;  }
+ | GEQ         { $$ = FLOW_OP_GEQ; }
+ | FALSE       { $$ = FLOW_OP_FALSE; }
  ;
 
 flow_logic_op:
-   OR          { $$ = 0x00; }
- | AND         { $$ = 0x40; }
+   OR          { $$ = FLOW_OP_OR; }
+ | AND         { $$ = FLOW_OP_AND; }
  ;
 
 flow_num_type_:
@@ -97,13 +97,13 @@ flow_num_opts:
 flow_num_opt_ext_expr:
    expr {
      flow_check_cf_value_length(this_flow, $1);
-     flow_builder_add_op_val(this_flow, 0b001, $1);
+     flow_builder_add_op_val(this_flow, FLOW_OP_EQ, $1);
    }
  | expr DDOT expr {
      flow_check_cf_value_length(this_flow, $1);
      flow_check_cf_value_length(this_flow, $3);
-     flow_builder_add_op_val(this_flow, 0b011, $1); /* >= */
-     flow_builder_add_op_val(this_flow, 0x40 | 0b101, $3); /* AND <= */
+     flow_builder_add_op_val(this_flow, FLOW_OP_GEQ, $1);
+     flow_builder_add_op_val(this_flow, FLOW_OP_AND | FLOW_OP_LEQ, $3);
    }
  ;
 
index 3fa6bac4b691c638b6ded33774087b7aa5d809d5..87ce02063f1a201f75ff13c19241185fc7bd801b 100644 (file)
@@ -754,7 +754,7 @@ flow_builder_add_val_mask(struct flow_builder *fb, byte op, u32 value, u32 mask)
   if (a)
   {
     flow_builder_add_op_val(fb, op ^ 0x01, a);
-    op |= 0x40;
+    op |= FLOW_OP_AND;
   }
 
   if (b)
@@ -897,28 +897,20 @@ flow_builder_clear(struct flow_builder *fb)
  */
 
 /* Flowspec operators for [op, value]+ pairs */
-#define FLOW_TRUE      0b000
-#define FLOW_EQ                0b001
-#define FLOW_GT                0b010
-#define FLOW_GTE       0b011
-#define FLOW_LT                0b100
-#define FLOW_LTE       0b101
-#define FLOW_NEQ       0b110
-#define FLOW_FALSE     0b111
 
 static const char *
 num_op_str(const byte *op)
 {
   switch (*op & 0x07)
   {
-  case FLOW_TRUE:      return "true";
-  case FLOW_EQ:        return "=";
-  case FLOW_GT:        return ">";
-  case FLOW_GTE:       return ">=";
-  case FLOW_LT:        return "<";
-  case FLOW_LTE:       return "<=";
-  case FLOW_NEQ:       return "!=";
-  case FLOW_FALSE:     return "false";
+  case FLOW_OP_TRUE:   return "true";
+  case FLOW_OP_EQ:     return "=";
+  case FLOW_OP_GT:     return ">";
+  case FLOW_OP_GEQ:    return ">=";
+  case FLOW_OP_LT:     return "<";
+  case FLOW_OP_LEQ:    return "<=";
+  case FLOW_OP_NEQ:    return "!=";
+  case FLOW_OP_FALSE:  return "false";
   }
 
   return NULL;
@@ -985,8 +977,8 @@ net_format_flow_num(buffer *b, const byte *part)
     {
       /* XXX: I don't like this so complicated if-tree */
       if (!isset_and(op) &&
-         ((num_op(     op) == FLOW_EQ) || (num_op(     op) == FLOW_GTE)) &&
-         ((num_op(last_op) == FLOW_EQ) || (num_op(last_op) == FLOW_LTE)))
+         ((num_op(     op) == FLOW_OP_EQ) || (num_op(     op) == FLOW_OP_GEQ)) &&
+         ((num_op(last_op) == FLOW_OP_EQ) || (num_op(last_op) == FLOW_OP_LEQ)))
       {
        b->pos--; /* Remove last char (it is a space) */
        buffer_puts(b, ",");
@@ -1002,7 +994,7 @@ net_format_flow_num(buffer *b, const byte *part)
     val = get_value(op+1, len);
 
     if (!isset_end(op) && !isset_and(op) && isset_and(op+1+len) &&
-       (num_op(op) == FLOW_GTE) && (num_op(op+1+len) == FLOW_LTE))
+       (num_op(op) == FLOW_OP_GEQ) && (num_op(op+1+len) == FLOW_OP_LEQ))
     {
       /* Display interval */
       buffer_print(b, "%u..", val);
@@ -1011,7 +1003,7 @@ net_format_flow_num(buffer *b, const byte *part)
       val = get_value(op+1, len);
       buffer_print(b, "%u", val);
     }
-    else if (num_op(op) == FLOW_EQ)
+    else if (num_op(op) == FLOW_OP_EQ)
     {
       buffer_print(b, "%u", val);
     }
index 185d5a1ccd89579042d48bb0c5311df049770460..4fe23da115ce9a9faf3859ff81494bd9730b34de 100644 (file)
 #include "lib/net.h"
 
 
+/* Flow component operators */
+#define FLOW_OP_TRUE           0x00    /* 0b000 */
+#define FLOW_OP_EQ             0x01    /* 0b001 */
+#define FLOW_OP_GT             0x02    /* 0b010 */
+#define FLOW_OP_GEQ            0x03    /* 0b011 */
+#define FLOW_OP_LT             0x04    /* 0b100 */
+#define FLOW_OP_LEQ            0x05    /* 0b101 */
+#define FLOW_OP_NEQ            0x06    /* 0b110 */
+#define FLOW_OP_FALSE          0x07    /* 0b111 */
+
+#define FLOW_OP_OR             0x00
+#define FLOW_OP_AND            0x40
+
+
 /* Types of components in flowspec */
 enum flow_type {
   FLOW_TYPE_DST_PREFIX                 =  1,
index 3d764df07c252419f6dab02c00b57310e2e050ec..361bb225c1d4d3ad42b4178db62bb76c3e5fbad1 100644 (file)
@@ -47,7 +47,7 @@ static void proto_shutdown_loop(struct timer *);
 static void proto_rethink_goal(struct proto *p);
 static char *proto_state_name(struct proto *p);
 static void channel_verify_limits(struct channel *c);
-static void channel_reset_limit(struct channel_limit *l);
+static inline void channel_reset_limit(struct channel_limit *l);
 
 
 static inline int proto_is_done(struct proto *p)
index 06cde4d3115c0c26f5c5c16135178bc1f058980a..b76efda6ece716ed74859506a7fc5c59bff0cee5 100644 (file)
@@ -248,7 +248,7 @@ bfd_check_authentication(struct bfd_proto *p, struct bfd_session *s, struct bfd_
     /* BFD CSNs are in 32-bit circular number space */
     u32 csn = ntohl(auth->csn);
     if (s->rx_csn_known &&
-       (((csn - s->rx_csn) > (3 * s->detect_mult)) ||
+       (((csn - s->rx_csn) > (3 * (uint) s->detect_mult)) ||
         (meticulous && (csn == s->rx_csn))))
     {
       /* We want to report both new and old CSN */
index 9dc492b76e9e2c0c00a787d4228662ac37791f71..e97809c83dd4ff131f422e6e91ace5854a0b6b62 100644 (file)
@@ -450,7 +450,7 @@ rip_send_response(struct rip_proto *p, struct rip_iface *ifa)
 
     /* Stale entries that should be removed */
     if ((en->valid == RIP_ENTRY_STALE) &&
-       ((en->changed + ifa->cf->garbage_time) <= now))
+       ((en->changed + (bird_clock_t) ifa->cf->garbage_time) <= now))
       goto next_entry;
 
     /* Triggered updates */
index 157093aabaf3babaa01d07d6ba24e89032cc2061..55fb47c569a941bb025a512066bc468051d7f26f 100644 (file)
@@ -684,7 +684,7 @@ rip_reconfigure_iface(struct rip_proto *p, struct rip_iface *ifa, struct rip_ifa
 
   rip_iface_update_buffers(ifa);
 
-  if (ifa->next_regular > (now + new->update_time))
+  if (ifa->next_regular > (now + (bird_clock_t) new->update_time))
     ifa->next_regular = now + (random() % new->update_time) + 1;
 
   if (new->check_link != old->check_link)
index 8f44b007acb8390b2ffb3c68d386a8655ad22aea..40d1196ea835afd1cacd39ad51f5ed01720c14f6 100644 (file)
@@ -62,8 +62,8 @@
 
 #ifndef HAVE_STRUCT_RTVIA
 struct rtvia {
-       __kernel_sa_family_t    rtvia_family;
-       __u8                    rtvia_addr[0];
+       unsigned short  rtvia_family;
+       u8              rtvia_addr[0];
 };
 #endif
 
index d1246ea5b420e81a2212237099acc17af01df7cf..0cf48c9dd9953c5ef3654ccd6d8bcca2a7277027 100644 (file)
@@ -1344,6 +1344,7 @@ sk_tcp_connected(sock *s)
   s->tx_hook(s);
 }
 
+#ifdef HAVE_LIBSSH
 static void
 sk_ssh_connected(sock *s)
 {
@@ -1351,6 +1352,7 @@ sk_ssh_connected(sock *s)
   s->type = SK_SSH;
   s->tx_hook(s);
 }
+#endif
 
 static int
 sk_passive_connected(sock *s, int type)