diff options
Diffstat (limited to 'sysdep/unix')
-rw-r--r-- | sysdep/unix/krt.Y | 3 | ||||
-rw-r--r-- | sysdep/unix/krt.c | 8 | ||||
-rw-r--r-- | sysdep/unix/krt.h | 3 | ||||
-rw-r--r-- | sysdep/unix/unix.h | 6 |
4 files changed, 6 insertions, 14 deletions
diff --git a/sysdep/unix/krt.Y b/sysdep/unix/krt.Y index e769ec0f..eb0ae109 100644 --- a/sysdep/unix/krt.Y +++ b/sysdep/unix/krt.Y @@ -69,8 +69,7 @@ kif_item: } | PRIMARY opttext net_or_ipa { struct kif_primary_item *kpi = cfg_alloc(sizeof (struct kif_primary_item)); - kpi->prefix = IPA_NONE; /* XXXX */ - kpi->pxlen = 0; /* XXXX */ + kpi->addr = $3.n; add_tail(&THIS_KIF->primary, &kpi->n); } ; diff --git a/sysdep/unix/krt.c b/sysdep/unix/krt.c index 73324f38..41293a06 100644 --- a/sysdep/unix/krt.c +++ b/sysdep/unix/krt.c @@ -131,14 +131,14 @@ prefer_addr(struct ifa *a, struct ifa *b) } static inline struct ifa * -find_preferred_ifa(struct iface *i, ip_addr prefix, ip_addr mask) +find_preferred_ifa(struct iface *i, const net_addr *n) { struct ifa *a, *b = NULL; WALK_LIST(a, i->addrs) { if (!(a->flags & IA_SECONDARY) && - ipa_equal(ipa_and(a->ip, mask), prefix) && + (!n || ipa_in_netX(a->ip, n)) && (!b || prefer_addr(a, b))) b = a; } @@ -156,14 +156,14 @@ kif_choose_primary(struct iface *i) WALK_LIST(it, cf->primary) { if (!it->pattern || patmatch(it->pattern, i->name)) - if (a = find_preferred_ifa(i, it->prefix, ipa_mkmask(it->pxlen))) + if (a = find_preferred_ifa(i, &it->addr)) return a; } if (a = kif_get_primary_ip(i)) return a; - return find_preferred_ifa(i, IPA_NONE, IPA_NONE); + return find_preferred_ifa(i, NULL); } diff --git a/sysdep/unix/krt.h b/sysdep/unix/krt.h index 4b66ea83..f05dc37e 100644 --- a/sysdep/unix/krt.h +++ b/sysdep/unix/krt.h @@ -97,8 +97,7 @@ extern struct protocol proto_unix_iface; struct kif_primary_item { node n; byte *pattern; - ip_addr prefix; - int pxlen; + net_addr addr; }; struct kif_config { diff --git a/sysdep/unix/unix.h b/sysdep/unix/unix.h index 58ceab1e..6e788f08 100644 --- a/sysdep/unix/unix.h +++ b/sysdep/unix/unix.h @@ -80,14 +80,8 @@ static inline ip_addr ipa_from_sa(sockaddr *sa) static inline struct in_addr ipa_to_in4(ip_addr a) { return (struct in_addr) { htonl(ipa_to_u32(a)) }; } -#ifdef IPV6 static inline struct in6_addr ipa_to_in6(ip_addr a) { return (struct in6_addr) { .s6_addr32 = { htonl(_I0(a)), htonl(_I1(a)), htonl(_I2(a)), htonl(_I3(a)) } }; } -#else -/* Temporary dummy */ -static inline struct in6_addr ipa_to_in6(ip_addr a) -{ return (struct in6_addr) { .s6_addr32 = { 0, 0, 0, 0 } }; } -#endif void sockaddr_fill(sockaddr *sa, int af, ip_addr a, struct iface *ifa, uint port); int sockaddr_read(sockaddr *sa, int af, ip_addr *a, struct iface **ifa, uint *port); |