dhcpv6, tap, tcp: Use IN6_ARE_ADDR_EQUAL instead of open-coded memcmp()
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
This commit is contained in:
parent
5eb7604203
commit
5ca555cf78
3 changed files with 9 additions and 9 deletions
2
dhcpv6.c
2
dhcpv6.c
|
@ -354,7 +354,7 @@ ia_ta:
|
||||||
|
|
||||||
req_addr = (struct in6_addr *)(ia_addr + 1);
|
req_addr = (struct in6_addr *)(ia_addr + 1);
|
||||||
|
|
||||||
if (memcmp(addr, req_addr, sizeof(*addr))) {
|
if (!IN6_ARE_ADDR_EQUAL(addr, req_addr)) {
|
||||||
info("DHCPv6: requested address %s not on link",
|
info("DHCPv6: requested address %s not on link",
|
||||||
inet_ntop(AF_INET6, req_addr,
|
inet_ntop(AF_INET6, req_addr,
|
||||||
buf, sizeof(buf)));
|
buf, sizeof(buf)));
|
||||||
|
|
4
tap.c
4
tap.c
|
@ -542,8 +542,8 @@ resume:
|
||||||
#define L4_MATCH(ip6h, proto, uh, seq) \
|
#define L4_MATCH(ip6h, proto, uh, seq) \
|
||||||
(seq->protocol == proto && \
|
(seq->protocol == proto && \
|
||||||
seq->source == uh->source && seq->dest == uh->dest && \
|
seq->source == uh->source && seq->dest == uh->dest && \
|
||||||
!memcmp(&seq->saddr, &ip6h->saddr, sizeof(seq->saddr)) && \
|
IN6_ARE_ADDR_EQUAL(&seq->saddr, &ip6h->saddr) && \
|
||||||
!memcmp(&seq->daddr, &ip6h->daddr, sizeof(seq->daddr)))
|
IN6_ARE_ADDR_EQUAL(&seq->daddr, &ip6h->daddr))
|
||||||
|
|
||||||
#define L4_SET(ip6h, proto, uh, seq) \
|
#define L4_SET(ip6h, proto, uh, seq) \
|
||||||
do { \
|
do { \
|
||||||
|
|
12
tcp.c
12
tcp.c
|
@ -853,7 +853,7 @@ static int tcp_rtt_dst_low(struct tcp_conn *conn)
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < LOW_RTT_TABLE_SIZE; i++)
|
for (i = 0; i < LOW_RTT_TABLE_SIZE; i++)
|
||||||
if (!memcmp(&conn->a.a6, low_rtt_dst + i, sizeof(conn->a.a6)))
|
if (IN6_ARE_ADDR_EQUAL(&conn->a.a6, low_rtt_dst + i))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -874,7 +874,7 @@ static void tcp_rtt_dst_check(struct tcp_conn *conn, struct tcp_info *tinfo)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (i = 0; i < LOW_RTT_TABLE_SIZE; i++) {
|
for (i = 0; i < LOW_RTT_TABLE_SIZE; i++) {
|
||||||
if (!memcmp(&conn->a.a6, low_rtt_dst + i, sizeof(conn->a.a6)))
|
if (IN6_ARE_ADDR_EQUAL(&conn->a.a6, low_rtt_dst + i))
|
||||||
return;
|
return;
|
||||||
if (hole == -1 && IN6_IS_ADDR_UNSPECIFIED(low_rtt_dst + i))
|
if (hole == -1 && IN6_IS_ADDR_UNSPECIFIED(low_rtt_dst + i))
|
||||||
hole = i;
|
hole = i;
|
||||||
|
@ -1181,7 +1181,7 @@ static int tcp_hash_match(struct tcp_conn *conn, int af, void *addr,
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
if (af == AF_INET6 &&
|
if (af == AF_INET6 &&
|
||||||
!memcmp(&conn->a.a6, addr, sizeof(conn->a.a6)) &&
|
IN6_ARE_ADDR_EQUAL(&conn->a.a6, addr) &&
|
||||||
conn->tap_port == tap_port && conn->sock_port == sock_port)
|
conn->tap_port == tap_port && conn->sock_port == sock_port)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
@ -2047,7 +2047,7 @@ static void tcp_conn_from_tap(struct ctx *c, int af, void *addr,
|
||||||
if (!c->no_map_gw) {
|
if (!c->no_map_gw) {
|
||||||
if (af == AF_INET && addr4.sin_addr.s_addr == c->gw4)
|
if (af == AF_INET && addr4.sin_addr.s_addr == c->gw4)
|
||||||
addr4.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
|
addr4.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
|
||||||
if (af == AF_INET6 && !memcmp(addr, &c->gw6, sizeof(c->gw6)))
|
if (af == AF_INET6 && IN6_ARE_ADDR_EQUAL(addr, &c->gw6))
|
||||||
addr6.sin6_addr = in6addr_loopback;
|
addr6.sin6_addr = in6addr_loopback;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2699,8 +2699,8 @@ static void tcp_conn_from_sock(struct ctx *c, union epoll_ref ref,
|
||||||
memcpy(&sa6, &sa, sizeof(sa6));
|
memcpy(&sa6, &sa, sizeof(sa6));
|
||||||
|
|
||||||
if (IN6_IS_ADDR_LOOPBACK(&sa6.sin6_addr) ||
|
if (IN6_IS_ADDR_LOOPBACK(&sa6.sin6_addr) ||
|
||||||
!memcmp(&sa6.sin6_addr, &c->addr6_seen, sizeof(c->gw6)) ||
|
IN6_ARE_ADDR_EQUAL(&sa6.sin6_addr, &c->addr6_seen) ||
|
||||||
!memcmp(&sa6.sin6_addr, &c->addr6, sizeof(c->gw6))) {
|
IN6_ARE_ADDR_EQUAL(&sa6.sin6_addr, &c->addr6)) {
|
||||||
struct in6_addr *src;
|
struct in6_addr *src;
|
||||||
|
|
||||||
if (IN6_IS_ADDR_LINKLOCAL(&c->gw6))
|
if (IN6_IS_ADDR_LINKLOCAL(&c->gw6))
|
||||||
|
|
Loading…
Reference in a new issue