]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Fix behavior of ipa_opposite().
authorMartin Mares <mj@ucw.cz>
Mon, 25 Aug 2008 11:19:49 +0000 (11:19 +0000)
committerMartin Mares <mj@ucw.cz>
Mon, 25 Aug 2008 11:19:49 +0000 (11:19 +0000)
It was giving wrong results on /30 networks.

lib/ip.c
lib/ipv4.h
sysdep/linux/netlink/netlink.c
sysdep/unix/krt-iface.c

index b940bf53bf495bb379985ded904dc63074a6d76e..0afe97967409c5700ec04f6a77ae7ba60c39af95 100644 (file)
--- a/lib/ip.c
+++ b/lib/ip.c
@@ -153,13 +153,14 @@ int ipa_classify(ip_addr x) { DUMMY }
 /**
  * ipa_opposite - return address of point-to-point neighbor
  * @x: IP address of our end of the link
+ * @pxlen: network prefix length
  *
  * ipa_opposite() returns an address of the opposite end of a numbered
  * point-to-point link.
  *
  * This function is available in IPv4 version only.
  */
-ip_addr ipa_opposite(ip_addr x) { DUMMY }
+ip_addr ipa_opposite(ip_addr x, int pxlen) { DUMMY }
 
 /**
  * ipa_class_mask - guess netmask according to address class
index 49aa13a6eb4136d8e3d93f836aac3f53426ae56b..4c4fab90f196ff93ef1eb9aa323fd6e5ebb6cd39 100644 (file)
@@ -53,7 +53,7 @@ typedef u32 ip_addr;
 #define ipa_hton(x) x = _MI(htonl(_I(x)))
 #define ipa_ntoh(x) x = _MI(ntohl(_I(x)))
 #define ipa_classify(x) ipv4_classify(_I(x))
-#define ipa_opposite(x) _MI(_I(x) ^ 1)
+#define ipa_opposite(x,len) _MI(_I(x) ^ (len == 30 ? 3 : 1))
 #define ipa_class_mask(x) _MI(ipv4_class_mask(_I(x)))
 #define ipa_from_u32(x) _MI(x)
 #define ipa_to_u32(x) _I(x)
index a54e1157198497c0ae4a9b9e4e890cc5914b74b6..a70428efe33d513c1fc84661a176655362d5c41d 100644 (file)
@@ -377,7 +377,7 @@ nl_parse_addr(struct nlmsghdr *h)
       ifa.brd = ipa_or(ifa.ip, ipa_not(netmask));
 #ifndef IPV6
       if (i->ifa_prefixlen == BITS_PER_IP_ADDRESS - 2)
-       ifa.opposite = ipa_opposite(ifa.ip);
+       ifa.opposite = ipa_opposite(ifa.ip, i->ifa_prefixlen);
       if ((ifi->flags & IF_BROADCAST) && a[IFA_BROADCAST])
        {
          memcpy(&xbrd, RTA_DATA(a[IFA_BROADCAST]), sizeof(xbrd));
index 5cc788079abf87f5084a6a20533c8a336d0e5774..37f9d0bd8ea6bef1f48739500098ee944f92e116 100644 (file)
@@ -140,7 +140,7 @@ scan_ifs(struct ifreq *r, int cnt)
          if (a.pxlen < 30)
            i.flags |= IF_MULTIACCESS;
          else
-           a.opposite = ipa_opposite(a.ip);
+           a.opposite = ipa_opposite(a.ip, a.pxlen);
        }
       else
        a.brd = a.opposite;