diff options
-rw-r--r-- | conf/flowspec.Y | 26 | ||||
-rw-r--r-- | lib/flowspec.c | 34 | ||||
-rw-r--r-- | lib/flowspec.h | 14 | ||||
-rw-r--r-- | nest/proto.c | 2 | ||||
-rw-r--r-- | proto/bfd/packets.c | 2 | ||||
-rw-r--r-- | proto/rip/packets.c | 2 | ||||
-rw-r--r-- | proto/rip/rip.c | 2 | ||||
-rw-r--r-- | sysdep/linux/netlink.c | 4 | ||||
-rw-r--r-- | sysdep/unix/io.c | 2 |
9 files changed, 48 insertions, 40 deletions
diff --git a/conf/flowspec.Y b/conf/flowspec.Y index a47d453b..8c72854c 100644 --- a/conf/flowspec.Y +++ b/conf/flowspec.Y @@ -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); } ; diff --git a/lib/flowspec.c b/lib/flowspec.c index 3fa6bac4..87ce0206 100644 --- a/lib/flowspec.c +++ b/lib/flowspec.c @@ -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); } diff --git a/lib/flowspec.h b/lib/flowspec.h index 185d5a1c..4fe23da1 100644 --- a/lib/flowspec.h +++ b/lib/flowspec.h @@ -14,6 +14,20 @@ #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, diff --git a/nest/proto.c b/nest/proto.c index 3d764df0..361bb225 100644 --- a/nest/proto.c +++ b/nest/proto.c @@ -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) diff --git a/proto/bfd/packets.c b/proto/bfd/packets.c index 06cde4d3..b76efda6 100644 --- a/proto/bfd/packets.c +++ b/proto/bfd/packets.c @@ -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 */ diff --git a/proto/rip/packets.c b/proto/rip/packets.c index 9dc492b7..e97809c8 100644 --- a/proto/rip/packets.c +++ b/proto/rip/packets.c @@ -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 */ diff --git a/proto/rip/rip.c b/proto/rip/rip.c index 157093aa..55fb47c5 100644 --- a/proto/rip/rip.c +++ b/proto/rip/rip.c @@ -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) diff --git a/sysdep/linux/netlink.c b/sysdep/linux/netlink.c index 8f44b007..40d1196e 100644 --- a/sysdep/linux/netlink.c +++ b/sysdep/linux/netlink.c @@ -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 diff --git a/sysdep/unix/io.c b/sysdep/unix/io.c index d1246ea5..0cf48c9d 100644 --- a/sysdep/unix/io.c +++ b/sysdep/unix/io.c @@ -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) |