Some minor fixes.

This commit is contained in:
Ondrej Zajicek 2012-01-09 02:40:57 +01:00
parent 3f58437405
commit d7f469c15c
4 changed files with 20 additions and 19 deletions

View file

@ -831,7 +831,7 @@ bgp_set_next_hop(struct bgp_proto *p, rta *a)
if (p->cf->gw_mode == GW_DIRECT) if (p->cf->gw_mode == GW_DIRECT)
{ {
neighbor *ng; neighbor *ng = NULL;
if (ipa_nonzero(*nexthop)) if (ipa_nonzero(*nexthop))
ng = neigh_find(&p->p, nexthop, 0); ng = neigh_find(&p->p, nexthop, 0);

View file

@ -134,9 +134,9 @@ krt_sock_send(int cmd, rte *e)
_I0(gw) = 0xfe800000 | (i->index & 0x0000ffff); _I0(gw) = 0xfe800000 | (i->index & 0x0000ffff);
#endif #endif
fill_in_sockaddr(&dst, net->n.prefix, 0); fill_in_sockaddr(&dst, net->n.prefix, NULL, 0);
fill_in_sockaddr(&mask, ipa_mkmask(net->n.pxlen), 0); fill_in_sockaddr(&mask, ipa_mkmask(net->n.pxlen), NULL, 0);
fill_in_sockaddr(&gate, gw, 0); fill_in_sockaddr(&gate, gw, NULL, 0);
switch (a->dest) switch (a->dest)
{ {
@ -163,7 +163,7 @@ krt_sock_send(int cmd, rte *e)
return -1; return -1;
} }
fill_in_sockaddr(&gate, i->addr->ip, 0); fill_in_sockaddr(&gate, i->addr->ip, NULL, 0);
msg.rtm.rtm_addrs |= RTA_GATEWAY; msg.rtm.rtm_addrs |= RTA_GATEWAY;
} }
break; break;
@ -274,19 +274,19 @@ krt_read_rt(struct ks_msg *msg, struct krt_proto *p, int scan)
GETADDR(&mask, RTA_NETMASK); GETADDR(&mask, RTA_NETMASK);
if (sa_family_check(&dst)) if (sa_family_check(&dst))
get_sockaddr(&dst, &idst, NULL, 0); get_sockaddr(&dst, &idst, NULL, NULL, 0);
else else
SKIP("invalid DST"); SKIP("invalid DST");
/* We will check later whether we have valid gateway addr */ /* We will check later whether we have valid gateway addr */
if (sa_family_check(&gate)) if (sa_family_check(&gate))
get_sockaddr(&gate, &igate, NULL, 0); get_sockaddr(&gate, &igate, NULL, NULL, 0);
else else
igate = IPA_NONE; igate = IPA_NONE;
/* We do not test family for RTA_NETMASK, because BSD sends us /* We do not test family for RTA_NETMASK, because BSD sends us
some strange values, but interpreting them as IPv4/IPv6 works */ some strange values, but interpreting them as IPv4/IPv6 works */
get_sockaddr(&mask, &imask, NULL, 0); get_sockaddr(&mask, &imask, NULL, NULL, 0);
int c = ipa_classify_net(idst); int c = ipa_classify_net(idst);
if ((c < 0) || !(c & IADDR_HOST) || ((c & IADDR_SCOPE_MASK) <= SCOPE_LINK)) if ((c < 0) || !(c & IADDR_HOST) || ((c & IADDR_SCOPE_MASK) <= SCOPE_LINK))
@ -512,9 +512,9 @@ krt_read_addr(struct ks_msg *msg)
if (!sa_family_check(&addr)) if (!sa_family_check(&addr))
return; return;
get_sockaddr(&addr, &iaddr, NULL, 0); get_sockaddr(&addr, &iaddr, NULL, NULL, 0);
get_sockaddr(&mask, &imask, NULL, 0); get_sockaddr(&mask, &imask, NULL, NULL, 0);
get_sockaddr(&brd, &ibrd, NULL, 0); get_sockaddr(&brd, &ibrd, NULL, NULL, 0);
if ((masklen = ipa_mklen(imask)) < 0) if ((masklen = ipa_mklen(imask)) < 0)
{ {

View file

@ -609,8 +609,8 @@ sk_insert(sock *s)
#ifdef IPV6 #ifdef IPV6
static void void
fill_in_sockaddr(sockaddr *sa, ip_addr a, struct iface *ifa, unsigned port) fill_in_sockaddr(struct sockaddr_in6 *sa, ip_addr a, struct iface *ifa, unsigned port)
{ {
memset(sa, 0, sizeof (struct sockaddr_in6)); memset(sa, 0, sizeof (struct sockaddr_in6));
sa->sin6_family = AF_INET6; sa->sin6_family = AF_INET6;
@ -625,7 +625,7 @@ fill_in_sockaddr(sockaddr *sa, ip_addr a, struct iface *ifa, unsigned port)
sa->sin6_scope_id = ifa->index; sa->sin6_scope_id = ifa->index;
} }
static void void
get_sockaddr(struct sockaddr_in6 *sa, ip_addr *a, struct iface **ifa, unsigned *port, int check) get_sockaddr(struct sockaddr_in6 *sa, ip_addr *a, struct iface **ifa, unsigned *port, int check)
{ {
if (check && sa->sin6_family != AF_INET6) if (check && sa->sin6_family != AF_INET6)
@ -641,8 +641,8 @@ get_sockaddr(struct sockaddr_in6 *sa, ip_addr *a, struct iface **ifa, unsigned *
#else #else
static void void
fill_in_sockaddr(sockaddr *sa, ip_addr a, struct iface *ifa, unsigned port) fill_in_sockaddr(struct sockaddr_in *sa, ip_addr a, struct iface *ifa, unsigned port)
{ {
memset (sa, 0, sizeof (struct sockaddr_in)); memset (sa, 0, sizeof (struct sockaddr_in));
sa->sin_family = AF_INET; sa->sin_family = AF_INET;
@ -653,7 +653,7 @@ fill_in_sockaddr(sockaddr *sa, ip_addr a, struct iface *ifa, unsigned port)
set_inaddr(&sa->sin_addr, a); set_inaddr(&sa->sin_addr, a);
} }
static void void
get_sockaddr(struct sockaddr_in *sa, ip_addr *a, struct iface **ifa, unsigned *port, int check) get_sockaddr(struct sockaddr_in *sa, ip_addr *a, struct iface **ifa, unsigned *port, int check)
{ {
if (check && sa->sin_family != AF_INET) if (check && sa->sin_family != AF_INET)

View file

@ -45,11 +45,12 @@ static inline int sa_family_check(sockaddr *sa) { return sa->sin_family == AF_IN
#endif #endif
struct birdsock; struct birdsock;
struct iface;
void io_init(void); void io_init(void);
void io_loop(void); void io_loop(void);
// void fill_in_sockaddr(sockaddr *sa, ip_addr a, struct iface *ifa, unsigned port); void fill_in_sockaddr(sockaddr *sa, ip_addr a, struct iface *ifa, unsigned port);
// void get_sockaddr(struct sockaddr_in6 *sa, ip_addr *a, struct iface **ifa, unsigned *port, int check); void get_sockaddr(sockaddr *sa, ip_addr *a, struct iface **ifa, unsigned *port, int check);
void sk_open_unix(struct birdsock *s, char *name); void sk_open_unix(struct birdsock *s, char *name);
void *tracked_fopen(struct pool *, char *name, char *mode); void *tracked_fopen(struct pool *, char *name, char *mode);
void test_old_bird(char *path); void test_old_bird(char *path);