summaryrefslogtreecommitdiff
path: root/sysdep
diff options
context:
space:
mode:
authorOndrej Zajicek <santiago@crfreenet.org>2010-04-28 00:39:57 +0200
committerOndrej Zajicek <santiago@crfreenet.org>2010-04-28 00:39:57 +0200
commitba321706578de8402d50214a9e79a65835cdd821 (patch)
treea76b5e241ed7f7c698890f2f9fd26a3c35ed07b2 /sysdep
parent48b0814ace2d05f9fef093d9f309bfa186a6f365 (diff)
Better support for /31 networks.
Diffstat (limited to 'sysdep')
-rw-r--r--sysdep/bsd/krt-sock.c10
-rw-r--r--sysdep/linux/netlink/netlink.c6
-rw-r--r--sysdep/unix/krt-iface.c8
3 files changed, 20 insertions, 4 deletions
diff --git a/sysdep/bsd/krt-sock.c b/sysdep/bsd/krt-sock.c
index 4817df39..12ebe6de 100644
--- a/sysdep/bsd/krt-sock.c
+++ b/sysdep/bsd/krt-sock.c
@@ -546,7 +546,17 @@ krt_read_addr(struct ks_msg *msg)
#endif
if (iface->flags & IF_MULTIACCESS)
+ {
ifa.prefix = ipa_and(ifa.ip, ipa_mkmask(masklen));
+
+ if (i->ifa_prefixlen == BITS_PER_IP_ADDRESS - 1)
+ ifa.opposite = ipa_opposite_m1(ifa.ip);
+
+#ifndef IPV6
+ if (i->ifa_prefixlen == BITS_PER_IP_ADDRESS - 2)
+ ifa.opposite = ipa_opposite_m2(ifa.ip);
+#endif
+ }
else /* PtP iface */
{
ifa.flags |= IA_UNNUMBERED;
diff --git a/sysdep/linux/netlink/netlink.c b/sysdep/linux/netlink/netlink.c
index aa0f2c45..72f06cc2 100644
--- a/sysdep/linux/netlink/netlink.c
+++ b/sysdep/linux/netlink/netlink.c
@@ -390,9 +390,13 @@ nl_parse_addr(struct nlmsghdr *h)
ip_addr netmask = ipa_mkmask(ifa.pxlen);
ifa.prefix = ipa_and(ifa.ip, netmask);
ifa.brd = ipa_or(ifa.ip, ipa_not(netmask));
+ if (i->ifa_prefixlen == BITS_PER_IP_ADDRESS - 1)
+ ifa.opposite = ipa_opposite_m1(ifa.ip);
+
#ifndef IPV6
if (i->ifa_prefixlen == BITS_PER_IP_ADDRESS - 2)
- ifa.opposite = ipa_opposite(ifa.ip, i->ifa_prefixlen);
+ ifa.opposite = ipa_opposite_m2(ifa.ip);
+
if ((ifi->flags & IF_BROADCAST) && a[IFA_BROADCAST])
{
ip_addr xbrd;
diff --git a/sysdep/unix/krt-iface.c b/sysdep/unix/krt-iface.c
index e0158b6b..5fda0d1d 100644
--- a/sysdep/unix/krt-iface.c
+++ b/sysdep/unix/krt-iface.c
@@ -89,7 +89,7 @@ scan_ifs(struct ifreq *r, int cnt)
{ err = "SIOCGIFNETMASK"; goto faulty; }
get_sockaddr((struct sockaddr_in *) &r->ifr_addr, &netmask, NULL, 0);
l = ipa_mklen(netmask);
- if (l < 0 || l == 31)
+ if (l < 0)
{
log(L_ERR "%s: Invalid netmask (%x)", i.name, netmask);
goto bad;
@@ -139,8 +139,10 @@ scan_ifs(struct ifreq *r, int cnt)
i.flags |= IF_BROADCAST;
if (a.pxlen < 30)
i.flags |= IF_MULTIACCESS;
- else
- a.opposite = ipa_opposite(a.ip, a.pxlen);
+ if (a.pxlen == 30)
+ ifa.opposite = ipa_opposite_m2(ifa.ip);
+ if (a.pxlen == 31)
+ ifa.opposite = ipa_opposite_m1(ifa.ip);
}
else
a.brd = a.opposite;