On Mon, Sep 13, 2010 at 09:56:07PM +0300, Alexander Shikoff wrote:
> Hello,
> 
> I want to store prefixes in RIB with communities but I want to delete 
> communities when prefix is being announced to peer.
> I'm trying following function:
> 
> function bgp_out (int peer_as)
> {
>         if ! (source = RTS_BGP ) then return false;
>         if (0,MyASN) ~ bgp_community then return false;
>         if (0,peer_as) ~ bgp_community then return false;
> 
>         if ( (MyASN,MyASN) ~ bgp_community ) ||
>                 ( (MyASN,peer_as) ~ bgp_community ) then {
>                 bgp_community.delete([ (0,0)..(65535,65535) ]);
>                 print bgp_community;
>                 return true;
>         }
>         return false;
> }
> 
> But communities are not deleted, I see them in debug output.
> bgp_community.add works as expected.

This is a bug in the set code, could you try the attached patch
(together with the one i sent previously for another issue)?

-- 
Elen sila lumenn' omentielvo

Ondrej 'SanTiago' Zajicek (email: santi...@crfreenet.org)
OpenPGP encrypted e-mails preferred (KeyID 0x11DEADC3, wwwkeys.pgp.net)
"To err is human -- to blame it on a computer is even more so."
diff -uprN bird-1.2.4-o/filter/filter.c bird-1.2.4/filter/filter.c
--- bird-1.2.4-o/filter/filter.c	2010-09-11 20:08:48.000000000 +0200
+++ bird-1.2.4/filter/filter.c	2010-09-14 12:19:17.000000000 +0200
@@ -119,6 +119,13 @@ static inline int int_cmp(int i1, int i2
   else return 1;
 }
 
+static inline int uint_cmp(unsigned int i1, unsigned int i2)
+{
+  if (i1 == i2) return 0;
+  if (i1 < i2) return -1;
+  else return 1;
+}
+
 /**
  * val_compare - compare two values
  * @v1: first value
@@ -144,9 +151,9 @@ val_compare(struct f_val v1, struct f_va
 #ifndef IPV6
     /* IP->Quad implicit conversion */
     if ((v1.type == T_QUAD) && (v2.type == T_IP))
-      return int_cmp(v1.val.i, ipa_to_u32(v2.val.px.ip));
+      return uint_cmp(v1.val.i, ipa_to_u32(v2.val.px.ip));
     if ((v1.type == T_IP) && (v2.type == T_QUAD))
-      return int_cmp(ipa_to_u32(v1.val.px.ip), v2.val.i);
+      return uint_cmp(ipa_to_u32(v1.val.px.ip), v2.val.i);
 #endif
 
     debug( "Types do not match in val_compare\n" );
@@ -156,9 +163,10 @@ val_compare(struct f_val v1, struct f_va
   case T_ENUM:
   case T_INT:
   case T_BOOL:
+    return int_cmp(v1.val.i, v2.val.i);
   case T_PAIR:
   case T_QUAD:
-    return int_cmp(v1.val.i, v2.val.i);
+    return uint_cmp(v1.val.i, v2.val.i);
   case T_IP:
     return ipa_compare(v1.val.px.ip, v2.val.px.ip);
   case T_PREFIX:

Reply via email to