Handling MED value

Eiichiro Watanabe watanabe at mfeed.ad.jp
Tue Dec 13 07:15:12 CET 2011


Hi Ondrej,

As you may know MED value of BGP protocol field has 2 octets, so it can be 0 through 4294967295.
On the other hand, bird defines the data type of MED as "int" and it limits the value
between -2000000000 and 2000000000 according to bird doc.

So, It doesn't seems to able to handle to compare MED value (or add/subtract them) in function correnctly.
I tried a workaround below, but it fails to load bird.conf with a syntax error message.

bird> configure
Reading configuration from /etc/bird.conf
/etc/bird.conf, line 123: Number out of range

120:function TEST()
121:{
122:  if (source = RTS_BGP) then {
123:    if (bgp_med + 100 < 4294967295) then {
124:      bgp_med = bgp_med + 100;
125:    } else {
126:      bgp_med = 4294967295;
127:   }
128:}
This function means boundary check:
When the MED value received + 100 is lower than 4294967295, it just updates MED.
Otherwise, it sets 4294967295. Cisco IOS does.

And the following commands instead of using the above function shows the MED value overflowed. 
bird> show route table master all
192.168.0.0/24  via 172.16.0.1 on eth0 [TEST 2011-12-13 14:39:30] * (100) [AS65000i]
        Type: BGP unicast univ
        BGP.origin: IGP
        BGP.as_path: 65000
        BGP.next_hop: 172.16.0.1
        BGP.med: 4294967294
        BGP.local_pref: 100
bird> show route table master filter { if source = RTS_BGP then {bgp_med = bgp_med + 100; accept;}} all
192.168.0.0/24  via 172.16.0.1 on eth0 [TEST 2011-12-13 14:39:30] * (100) [AS65000i]
        Type: BGP unicast univ
        BGP.origin: IGP
        BGP.as_path: 65000
        BGP.next_hop: 172.16.0.1
        BGP.med: 98 <= *This*
        BGP.local_pref: 100
bird>

We want a new data type which has the integer value between 0 and 4294967295 such as unsingned int (32bit) in C. What do you think?

Thanks,
Eiichiro



-- 
###################################################
Eiichiro Watanabe
Internet Multifeed Co.



More information about the Bird-users mailing list