mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-01-06 13:17:44 +03:00
icmp6-util: make icmp6_receive() accept the null source address
Fixes #29050. (cherry picked from commit4961f56646
) (cherry picked from commitfabdb2832d
) (cherry picked from commit262ba9bba6
)
This commit is contained in:
parent
4ebd2c664d
commit
29c801d2d7
@ -22,6 +22,13 @@ int icmp6_bind_router_advertisement(int index) {
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
static struct in6_addr dummy_link_local = {
|
||||
.s6_addr = {
|
||||
0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x12, 0x34, 0x56, 0xff, 0xfe, 0x78, 0x9a, 0xbc,
|
||||
},
|
||||
};
|
||||
|
||||
int icmp6_receive(
|
||||
int fd,
|
||||
void *iov_base,
|
||||
@ -34,6 +41,9 @@ int icmp6_receive(
|
||||
if (ret_timestamp)
|
||||
triple_timestamp_get(ret_timestamp);
|
||||
|
||||
if (ret_sender)
|
||||
*ret_sender = dummy_link_local;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -182,7 +182,7 @@ int icmp6_receive(
|
||||
sa.in6.sin6_family == AF_INET6) {
|
||||
|
||||
addr = sa.in6.sin6_addr;
|
||||
if (!in6_addr_is_link_local(&addr))
|
||||
if (!in6_addr_is_link_local(&addr) && !in6_addr_is_null(&addr))
|
||||
return -EADDRNOTAVAIL;
|
||||
|
||||
} else if (msg.msg_namelen > 0)
|
||||
|
@ -227,7 +227,7 @@ static int ndisc_recv(sd_event_source *s, int fd, uint32_t revents, void *userda
|
||||
|
||||
switch (r) {
|
||||
case -EADDRNOTAVAIL:
|
||||
log_ndisc(nd, "Received RA from non-link-local address. Ignoring.");
|
||||
log_ndisc(nd, "Received RA from neither link-local nor null address. Ignoring.");
|
||||
break;
|
||||
|
||||
case -EMULTIHOP:
|
||||
@ -246,6 +246,11 @@ static int ndisc_recv(sd_event_source *s, int fd, uint32_t revents, void *userda
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* The function icmp6_receive() accepts the null source address, but RFC 4861 Section 6.1.2 states
|
||||
* that hosts MUST discard messages with the null source address. */
|
||||
if (in6_addr_is_null(&rt->address))
|
||||
log_ndisc(nd, "Received RA from null address. Ignoring.");
|
||||
|
||||
(void) event_source_disable(nd->timeout_event_source);
|
||||
(void) ndisc_handle_datagram(nd, rt);
|
||||
return 0;
|
||||
|
@ -271,7 +271,7 @@ static int radv_recv(sd_event_source *s, int fd, uint32_t revents, void *userdat
|
||||
|
||||
switch (r) {
|
||||
case -EADDRNOTAVAIL:
|
||||
log_radv(ra, "Received RS from non-link-local address. Ignoring");
|
||||
log_radv(ra, "Received RS from neither link-local nor null address. Ignoring");
|
||||
break;
|
||||
|
||||
case -EMULTIHOP:
|
||||
@ -295,6 +295,9 @@ static int radv_recv(sd_event_source *s, int fd, uint32_t revents, void *userdat
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* TODO: if the sender address is null, check that the message does not have the source link-layer
|
||||
* address option. See RFC 4861 Section 6.1.1. */
|
||||
|
||||
const char *addr = IN6_ADDR_TO_STRING(&src);
|
||||
|
||||
r = radv_send(ra, &src, ra->lifetime_usec);
|
||||
|
@ -41,7 +41,8 @@ static void router_dump(sd_ndisc_router *rt) {
|
||||
assert_se(rt);
|
||||
|
||||
log_info("--");
|
||||
assert_se(sd_ndisc_router_get_address(rt, &addr) == -ENODATA);
|
||||
assert_se(sd_ndisc_router_get_address(rt, &addr) >= 0);
|
||||
log_info("Sender: %s", IN6_ADDR_TO_STRING(&addr));
|
||||
|
||||
assert_se(sd_ndisc_router_get_timestamp(rt, CLOCK_REALTIME, &t) >= 0);
|
||||
log_info("Timestamp: %s", FORMAT_TIMESTAMP(t));
|
||||
@ -176,6 +177,13 @@ int icmp6_bind_router_advertisement(int ifindex) {
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
static struct in6_addr dummy_link_local = {
|
||||
.s6_addr = {
|
||||
0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x12, 0x34, 0x56, 0xff, 0xfe, 0x78, 0x9a, 0xbc,
|
||||
},
|
||||
};
|
||||
|
||||
int icmp6_receive(
|
||||
int fd,
|
||||
void *iov_base,
|
||||
@ -188,6 +196,9 @@ int icmp6_receive(
|
||||
if (ret_timestamp)
|
||||
triple_timestamp_get(ret_timestamp);
|
||||
|
||||
if (ret_sender)
|
||||
*ret_sender = dummy_link_local;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user