diff options
author | Henning Brauer <henning@cvs.openbsd.org> | 2005-06-16 18:43:08 +0000 |
---|---|---|
committer | Henning Brauer <henning@cvs.openbsd.org> | 2005-06-16 18:43:08 +0000 |
commit | c199f848fd9ee5bdebd8c68028cab2d80a10deff (patch) | |
tree | 3149a4281d6e595cbb23b1aba972bc50b7bfc339 /usr.sbin/bgpd | |
parent | 332823dcdc4b0731c36d6f4a6ea4740ca1f77ae7 (diff) |
use prefixlen2mask() instead of doing the bitshifting by hand; fixes the
zero prefixlen case (32 bit shift on 32 bit val -> undefined result)
spotted by Moritz Grimm and otto
Diffstat (limited to 'usr.sbin/bgpd')
-rw-r--r-- | usr.sbin/bgpd/rde_update.c | 6 | ||||
-rw-r--r-- | usr.sbin/bgpd/session.c | 4 |
2 files changed, 5 insertions, 5 deletions
diff --git a/usr.sbin/bgpd/rde_update.c b/usr.sbin/bgpd/rde_update.c index 5fd755b298e..24a256aec57 100644 --- a/usr.sbin/bgpd/rde_update.c +++ b/usr.sbin/bgpd/rde_update.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde_update.c,v 1.35 2005/03/11 12:54:20 claudio Exp $ */ +/* $OpenBSD: rde_update.c,v 1.36 2005/06/16 18:43:07 henning Exp $ */ /* * Copyright (c) 2004 Claudio Jeker <claudio@openbsd.org> @@ -620,8 +620,8 @@ up_generate_attr(struct rde_peer *peer, struct update_attr *upa, /* ebgp directly connected */ if (a->nexthop != NULL && a->nexthop->flags & NEXTHOP_CONNECTED) { - mask = 0xffffffff << (32 - a->nexthop->nexthop_netlen); - mask = htonl(mask); + mask = htonl( + prefixlen2mask(a->nexthop->nexthop_netlen)); if ((peer->remote_addr.v4.s_addr & mask) == (a->nexthop->nexthop_net.v4.s_addr & mask)) /* nexthop and peer are in the same net */ diff --git a/usr.sbin/bgpd/session.c b/usr.sbin/bgpd/session.c index 80fed08f770..54208f3a99e 100644 --- a/usr.sbin/bgpd/session.c +++ b/usr.sbin/bgpd/session.c @@ -1,4 +1,4 @@ -/* $OpenBSD: session.c,v 1.227 2005/06/09 12:31:38 claudio Exp $ */ +/* $OpenBSD: session.c,v 1.228 2005/06/16 18:43:07 henning Exp $ */ /* * Copyright (c) 2003, 2004, 2005 Henning Brauer <henning@openbsd.org> @@ -2518,7 +2518,7 @@ session_match_mask(struct peer *p, struct sockaddr *ip) struct in6_addr mask; if (p->conf.remote_addr.af == AF_INET) { - v4mask = htonl(0xffffffff << (32 - p->conf.remote_masklen)); + v4mask = htonl(prefixlen2mask(p->conf.remote_masklen)); if (p->conf.remote_addr.v4.s_addr == ((((struct sockaddr_in *)ip)->sin_addr.s_addr) & v4mask)) return (1); |