mirror of
https://github.com/systemd/systemd-stable.git
synced 2024-12-22 13:33:56 +03:00
libsystemd-network: make log_dhcp_client() or friends include interface name
This commit is contained in:
parent
61a9fa8f0c
commit
353887831b
@ -12,6 +12,7 @@
|
||||
#include "sd-dhcp-client.h"
|
||||
|
||||
#include "dhcp-protocol.h"
|
||||
#include "log-link.h"
|
||||
#include "socket-util.h"
|
||||
|
||||
typedef struct sd_dhcp_option {
|
||||
@ -65,5 +66,15 @@ int dhcp_packet_verify_headers(DHCPPacket *packet, size_t len, bool checksum, ui
|
||||
#define DHCP_CLIENT_DONT_DESTROY(client) \
|
||||
_cleanup_(sd_dhcp_client_unrefp) _unused_ sd_dhcp_client *_dont_destroy_##client = sd_dhcp_client_ref(client)
|
||||
|
||||
#define log_dhcp_client_errno(client, error, fmt, ...) log_internal(LOG_DEBUG, error, PROJECT_FILE, __LINE__, __func__, "DHCP CLIENT (0x%x): " fmt, client->xid, ##__VA_ARGS__)
|
||||
#define log_dhcp_client(client, fmt, ...) log_dhcp_client_errno(client, 0, fmt, ##__VA_ARGS__)
|
||||
#define log_dhcp_client_errno(client, error, fmt, ...) \
|
||||
({ \
|
||||
int _e = (error); \
|
||||
if (DEBUG_LOGGING) \
|
||||
log_interface_full_errno( \
|
||||
sd_dhcp_client_get_ifname(client), \
|
||||
LOG_DEBUG, _e, "DHCPv4 client: " fmt, \
|
||||
##__VA_ARGS__); \
|
||||
-ERRNO_VALUE(_e); \
|
||||
})
|
||||
#define log_dhcp_client(client, fmt, ...) \
|
||||
log_dhcp_client_errno(client, 0, fmt, ##__VA_ARGS__)
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
#include "dhcp-internal.h"
|
||||
#include "ordered-set.h"
|
||||
#include "log.h"
|
||||
#include "log-link.h"
|
||||
#include "time-util.h"
|
||||
|
||||
typedef enum DHCPRawOption {
|
||||
@ -86,9 +86,6 @@ typedef struct DHCPRequest {
|
||||
uint32_t lifetime;
|
||||
} DHCPRequest;
|
||||
|
||||
#define log_dhcp_server(client, fmt, ...) log_internal(LOG_DEBUG, 0, PROJECT_FILE, __LINE__, __func__, "DHCP SERVER: " fmt, ##__VA_ARGS__)
|
||||
#define log_dhcp_server_errno(client, error, fmt, ...) log_internal(LOG_DEBUG, error, PROJECT_FILE, __LINE__, __func__, "DHCP SERVER: " fmt, ##__VA_ARGS__)
|
||||
|
||||
int dhcp_server_handle_message(sd_dhcp_server *server, DHCPMessage *message,
|
||||
size_t length);
|
||||
int dhcp_server_send_packet(sd_dhcp_server *server,
|
||||
@ -97,3 +94,16 @@ int dhcp_server_send_packet(sd_dhcp_server *server,
|
||||
|
||||
void client_id_hash_func(const DHCPClientId *p, struct siphash *state);
|
||||
int client_id_compare_func(const DHCPClientId *a, const DHCPClientId *b);
|
||||
|
||||
#define log_dhcp_server_errno(server, error, fmt, ...) \
|
||||
({ \
|
||||
int _e = (error); \
|
||||
if (DEBUG_LOGGING) \
|
||||
log_interface_full_errno( \
|
||||
sd_dhcp_server_get_ifname(server), \
|
||||
LOG_DEBUG, _e, "DHCPv4 server: " fmt, \
|
||||
##__VA_ARGS__); \
|
||||
-ERRNO_VALUE(_e); \
|
||||
})
|
||||
#define log_dhcp_server(server, fmt, ...) \
|
||||
log_dhcp_server_errno(server, 0, fmt, ##__VA_ARGS__)
|
||||
|
@ -9,9 +9,11 @@
|
||||
#include <netinet/in.h>
|
||||
|
||||
#include "sd-event.h"
|
||||
#include "sd-dhcp6-client.h"
|
||||
|
||||
#include "list.h"
|
||||
#include "hashmap.h"
|
||||
#include "list.h"
|
||||
#include "log-link.h"
|
||||
#include "macro.h"
|
||||
#include "sparse-endian.h"
|
||||
|
||||
@ -78,7 +80,7 @@ struct ia_ta {
|
||||
be32_t id;
|
||||
} _packed_;
|
||||
|
||||
struct DHCP6IA {
|
||||
typedef struct DHCP6IA {
|
||||
uint16_t type;
|
||||
union {
|
||||
struct ia_na ia_na;
|
||||
@ -87,12 +89,7 @@ struct DHCP6IA {
|
||||
};
|
||||
|
||||
LIST_HEAD(DHCP6Address, addresses);
|
||||
};
|
||||
|
||||
typedef struct DHCP6IA DHCP6IA;
|
||||
|
||||
#define log_dhcp6_client_errno(p, error, fmt, ...) log_internal(LOG_DEBUG, error, PROJECT_FILE, __LINE__, __func__, "DHCPv6 CLIENT: " fmt, ##__VA_ARGS__)
|
||||
#define log_dhcp6_client(p, fmt, ...) log_dhcp6_client_errno(p, 0, fmt, ##__VA_ARGS__)
|
||||
} DHCP6IA;
|
||||
|
||||
int dhcp6_option_append(uint8_t **buf, size_t *buflen, uint16_t code,
|
||||
size_t optlen, const void *optval);
|
||||
@ -105,7 +102,7 @@ int dhcp6_option_append_vendor_option(uint8_t **buf, size_t *buflen, OrderedHash
|
||||
int dhcp6_option_parse(uint8_t **buf, size_t *buflen, uint16_t *optcode,
|
||||
size_t *optlen, uint8_t **optvalue);
|
||||
int dhcp6_option_parse_status(DHCP6Option *option, size_t len);
|
||||
int dhcp6_option_parse_ia(DHCP6Option *iaoption, DHCP6IA *ia, uint16_t *ret_status_code);
|
||||
int dhcp6_option_parse_ia(sd_dhcp6_client *client, DHCP6Option *iaoption, DHCP6IA *ia, uint16_t *ret_status_code);
|
||||
int dhcp6_option_parse_ip6addrs(uint8_t *optval, uint16_t optlen,
|
||||
struct in6_addr **addrs, size_t count,
|
||||
size_t *allocated);
|
||||
@ -121,3 +118,16 @@ const char *dhcp6_message_type_to_string(int s) _const_;
|
||||
int dhcp6_message_type_from_string(const char *s) _pure_;
|
||||
const char *dhcp6_message_status_to_string(int s) _const_;
|
||||
int dhcp6_message_status_from_string(const char *s) _pure_;
|
||||
|
||||
#define log_dhcp6_client_errno(client, error, fmt, ...) \
|
||||
({ \
|
||||
int _e = (error); \
|
||||
if (DEBUG_LOGGING) \
|
||||
log_interface_full_errno( \
|
||||
sd_dhcp6_client_get_ifname(client), \
|
||||
LOG_DEBUG, _e, "DHCPv6 client: " fmt, \
|
||||
##__VA_ARGS__); \
|
||||
-ERRNO_VALUE(_e); \
|
||||
})
|
||||
#define log_dhcp6_client(client, fmt, ...) \
|
||||
log_dhcp6_client_errno(client, 0, fmt, ##__VA_ARGS__)
|
||||
|
@ -425,7 +425,7 @@ int dhcp6_option_parse_status(DHCP6Option *option, size_t len) {
|
||||
return be16toh(statusopt->status);
|
||||
}
|
||||
|
||||
static int dhcp6_option_parse_address(DHCP6Option *option, DHCP6IA *ia, uint32_t *ret_lifetime_valid) {
|
||||
static int dhcp6_option_parse_address(sd_dhcp6_client *client, DHCP6Option *option, DHCP6IA *ia, uint32_t *ret_lifetime_valid) {
|
||||
DHCP6AddressOption *addr_option = (DHCP6AddressOption *)option;
|
||||
DHCP6Address *addr;
|
||||
uint32_t lt_valid, lt_pref;
|
||||
@ -437,23 +437,20 @@ static int dhcp6_option_parse_address(DHCP6Option *option, DHCP6IA *ia, uint32_t
|
||||
lt_valid = be32toh(addr_option->iaaddr.lifetime_valid);
|
||||
lt_pref = be32toh(addr_option->iaaddr.lifetime_preferred);
|
||||
|
||||
if (lt_valid == 0 || lt_pref > lt_valid) {
|
||||
log_dhcp6_client(client,
|
||||
"Valid lifetime of an IA address is zero or "
|
||||
"preferred lifetime %"PRIu32" > valid lifetime %"PRIu32,
|
||||
lt_pref, lt_valid);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (lt_valid == 0 || lt_pref > lt_valid)
|
||||
return log_dhcp6_client_errno(client, SYNTHETIC_ERRNO(EINVAL),
|
||||
"Valid lifetime of an IA address is zero or "
|
||||
"preferred lifetime %"PRIu32" > valid lifetime %"PRIu32,
|
||||
lt_pref, lt_valid);
|
||||
|
||||
if (be16toh(option->len) + offsetof(DHCP6Option, data) > sizeof(*addr_option)) {
|
||||
r = dhcp6_option_parse_status((DHCP6Option *)addr_option->options, be16toh(option->len) + offsetof(DHCP6Option, data) - sizeof(*addr_option));
|
||||
if (r < 0)
|
||||
return r;
|
||||
if (r > 0) {
|
||||
log_dhcp6_client(client, "Non-zero status code '%s' for address is received",
|
||||
dhcp6_message_status_to_string(r));
|
||||
return -EINVAL;
|
||||
}
|
||||
if (r > 0)
|
||||
return log_dhcp6_client_errno(client, SYNTHETIC_ERRNO(EINVAL),
|
||||
"Non-zero status code '%s' for address is received",
|
||||
dhcp6_message_status_to_string(r));
|
||||
}
|
||||
|
||||
addr = new0(DHCP6Address, 1);
|
||||
@ -470,7 +467,7 @@ static int dhcp6_option_parse_address(DHCP6Option *option, DHCP6IA *ia, uint32_t
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int dhcp6_option_parse_pdprefix(DHCP6Option *option, DHCP6IA *ia, uint32_t *ret_lifetime_valid) {
|
||||
static int dhcp6_option_parse_pdprefix(sd_dhcp6_client *client, DHCP6Option *option, DHCP6IA *ia, uint32_t *ret_lifetime_valid) {
|
||||
DHCP6PDPrefixOption *pdprefix_option = (DHCP6PDPrefixOption *)option;
|
||||
DHCP6Address *prefix;
|
||||
uint32_t lt_valid, lt_pref;
|
||||
@ -482,23 +479,20 @@ static int dhcp6_option_parse_pdprefix(DHCP6Option *option, DHCP6IA *ia, uint32_
|
||||
lt_valid = be32toh(pdprefix_option->iapdprefix.lifetime_valid);
|
||||
lt_pref = be32toh(pdprefix_option->iapdprefix.lifetime_preferred);
|
||||
|
||||
if (lt_valid == 0 || lt_pref > lt_valid) {
|
||||
log_dhcp6_client(client,
|
||||
"Valid lifetieme of a PD prefix is zero or "
|
||||
"preferred lifetime %"PRIu32" > valid lifetime %"PRIu32,
|
||||
lt_pref, lt_valid);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (lt_valid == 0 || lt_pref > lt_valid)
|
||||
return log_dhcp6_client_errno(client, SYNTHETIC_ERRNO(EINVAL),
|
||||
"Valid lifetieme of a PD prefix is zero or "
|
||||
"preferred lifetime %"PRIu32" > valid lifetime %"PRIu32,
|
||||
lt_pref, lt_valid);
|
||||
|
||||
if (be16toh(option->len) + offsetof(DHCP6Option, data) > sizeof(*pdprefix_option)) {
|
||||
r = dhcp6_option_parse_status((DHCP6Option *)pdprefix_option->options, be16toh(option->len) + offsetof(DHCP6Option, data) - sizeof(*pdprefix_option));
|
||||
if (r < 0)
|
||||
return r;
|
||||
if (r > 0) {
|
||||
log_dhcp6_client(client, "Non-zero status code '%s' for PD prefix is received",
|
||||
dhcp6_message_status_to_string(r));
|
||||
return -EINVAL;
|
||||
}
|
||||
if (r > 0)
|
||||
return log_dhcp6_client_errno(client, SYNTHETIC_ERRNO(EINVAL),
|
||||
"Non-zero status code '%s' for PD prefix is received",
|
||||
dhcp6_message_status_to_string(r));
|
||||
}
|
||||
|
||||
prefix = new0(DHCP6Address, 1);
|
||||
@ -515,7 +509,7 @@ static int dhcp6_option_parse_pdprefix(DHCP6Option *option, DHCP6IA *ia, uint32_
|
||||
return 0;
|
||||
}
|
||||
|
||||
int dhcp6_option_parse_ia(DHCP6Option *iaoption, DHCP6IA *ia, uint16_t *ret_status_code) {
|
||||
int dhcp6_option_parse_ia(sd_dhcp6_client *client, DHCP6Option *iaoption, DHCP6IA *ia, uint16_t *ret_status_code) {
|
||||
uint32_t lt_t1, lt_t2, lt_valid = 0, lt_min = UINT32_MAX;
|
||||
uint16_t iatype, optlen;
|
||||
size_t iaaddr_offset;
|
||||
@ -541,10 +535,10 @@ int dhcp6_option_parse_ia(DHCP6Option *iaoption, DHCP6IA *ia, uint16_t *ret_stat
|
||||
lt_t1 = be32toh(ia->ia_na.lifetime_t1);
|
||||
lt_t2 = be32toh(ia->ia_na.lifetime_t2);
|
||||
|
||||
if (lt_t1 && lt_t2 && lt_t1 > lt_t2) {
|
||||
log_dhcp6_client(client, "IA NA T1 %"PRIu32"sec > T2 %"PRIu32"sec", lt_t1, lt_t2);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (lt_t1 && lt_t2 && lt_t1 > lt_t2)
|
||||
return log_dhcp6_client_errno(client, SYNTHETIC_ERRNO(EINVAL),
|
||||
"IA NA T1 %"PRIu32"sec > T2 %"PRIu32"sec",
|
||||
lt_t1, lt_t2);
|
||||
|
||||
break;
|
||||
|
||||
@ -559,10 +553,10 @@ int dhcp6_option_parse_ia(DHCP6Option *iaoption, DHCP6IA *ia, uint16_t *ret_stat
|
||||
lt_t1 = be32toh(ia->ia_pd.lifetime_t1);
|
||||
lt_t2 = be32toh(ia->ia_pd.lifetime_t2);
|
||||
|
||||
if (lt_t1 && lt_t2 && lt_t1 > lt_t2) {
|
||||
log_dhcp6_client(client, "IA PD T1 %"PRIu32"sec > T2 %"PRIu32"sec", lt_t1, lt_t2);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (lt_t1 && lt_t2 && lt_t1 > lt_t2)
|
||||
return log_dhcp6_client_errno(client, SYNTHETIC_ERRNO(EINVAL),
|
||||
"IA PD T1 %"PRIu32"sec > T2 %"PRIu32"sec",
|
||||
lt_t1, lt_t2);
|
||||
|
||||
break;
|
||||
|
||||
@ -594,12 +588,11 @@ int dhcp6_option_parse_ia(DHCP6Option *iaoption, DHCP6IA *ia, uint16_t *ret_stat
|
||||
switch (opt) {
|
||||
case SD_DHCP6_OPTION_IAADDR:
|
||||
|
||||
if (!IN_SET(ia->type, SD_DHCP6_OPTION_IA_NA, SD_DHCP6_OPTION_IA_TA)) {
|
||||
log_dhcp6_client(client, "IA Address option not in IA NA or TA option");
|
||||
return -EINVAL;
|
||||
}
|
||||
if (!IN_SET(ia->type, SD_DHCP6_OPTION_IA_NA, SD_DHCP6_OPTION_IA_TA))
|
||||
return log_dhcp6_client_errno(client, SYNTHETIC_ERRNO(EINVAL),
|
||||
"IA Address option not in IA NA or TA option");
|
||||
|
||||
r = dhcp6_option_parse_address(option, ia, <_valid);
|
||||
r = dhcp6_option_parse_address(client, option, ia, <_valid);
|
||||
if (r < 0 && r != -EINVAL)
|
||||
return r;
|
||||
if (r >= 0 && lt_valid < lt_min)
|
||||
@ -609,12 +602,11 @@ int dhcp6_option_parse_ia(DHCP6Option *iaoption, DHCP6IA *ia, uint16_t *ret_stat
|
||||
|
||||
case SD_DHCP6_OPTION_IA_PD_PREFIX:
|
||||
|
||||
if (!IN_SET(ia->type, SD_DHCP6_OPTION_IA_PD)) {
|
||||
log_dhcp6_client(client, "IA PD Prefix option not in IA PD option");
|
||||
return -EINVAL;
|
||||
}
|
||||
if (!IN_SET(ia->type, SD_DHCP6_OPTION_IA_PD))
|
||||
return log_dhcp6_client_errno(client, SYNTHETIC_ERRNO(EINVAL),
|
||||
"IA PD Prefix option not in IA PD option");
|
||||
|
||||
r = dhcp6_option_parse_pdprefix(option, ia, <_valid);
|
||||
r = dhcp6_option_parse_pdprefix(client, option, ia, <_valid);
|
||||
if (r < 0 && r != -EINVAL)
|
||||
return r;
|
||||
if (r >= 0 && lt_valid < lt_min)
|
||||
|
@ -5,7 +5,7 @@
|
||||
#include "sd-lldp.h"
|
||||
|
||||
#include "hashmap.h"
|
||||
#include "log.h"
|
||||
#include "log-link.h"
|
||||
#include "prioq.h"
|
||||
|
||||
struct sd_lldp {
|
||||
@ -33,8 +33,18 @@ struct sd_lldp {
|
||||
struct ether_addr filter_address;
|
||||
};
|
||||
|
||||
#define log_lldp_errno(error, fmt, ...) log_internal(LOG_DEBUG, error, PROJECT_FILE, __LINE__, __func__, "LLDP: " fmt, ##__VA_ARGS__)
|
||||
#define log_lldp(fmt, ...) log_lldp_errno(0, fmt, ##__VA_ARGS__)
|
||||
|
||||
const char* lldp_event_to_string(sd_lldp_event_t e) _const_;
|
||||
sd_lldp_event_t lldp_event_from_string(const char *s) _pure_;
|
||||
|
||||
#define log_lldp_errno(lldp, error, fmt, ...) \
|
||||
({ \
|
||||
int _e = (error); \
|
||||
if (DEBUG_LOGGING) \
|
||||
log_interface_full_errno( \
|
||||
sd_lldp_get_ifname(lldp), \
|
||||
LOG_DEBUG, _e, "LLDP: " fmt, \
|
||||
##__VA_ARGS__); \
|
||||
-ERRNO_VALUE(_e); \
|
||||
})
|
||||
#define log_lldp(lldp, fmt, ...) \
|
||||
log_lldp_errno(lldp, 0, fmt, ##__VA_ARGS__)
|
||||
|
@ -112,7 +112,7 @@ sd_lldp_neighbor *lldp_neighbor_new(size_t raw_size) {
|
||||
return n;
|
||||
}
|
||||
|
||||
static int parse_string(char **s, const void *q, size_t n) {
|
||||
static int parse_string(sd_lldp *lldp, char **s, const void *q, size_t n) {
|
||||
const char *p = q;
|
||||
char *k;
|
||||
|
||||
@ -120,7 +120,7 @@ static int parse_string(char **s, const void *q, size_t n) {
|
||||
assert(p || n == 0);
|
||||
|
||||
if (*s) {
|
||||
log_lldp("Found duplicate string, ignoring field.");
|
||||
log_lldp(lldp, "Found duplicate string, ignoring field.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -133,14 +133,14 @@ static int parse_string(char **s, const void *q, size_t n) {
|
||||
|
||||
/* Look for inner NULs */
|
||||
if (memchr(p, 0, n)) {
|
||||
log_lldp("Found inner NUL in string, ignoring field.");
|
||||
log_lldp(lldp, "Found inner NUL in string, ignoring field.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Let's escape weird chars, for security reasons */
|
||||
k = cescape_length(p, n);
|
||||
if (!k)
|
||||
return -ENOMEM;
|
||||
return log_oom_debug();
|
||||
|
||||
free(*s);
|
||||
*s = k;
|
||||
@ -156,27 +156,24 @@ int lldp_neighbor_parse(sd_lldp_neighbor *n) {
|
||||
|
||||
assert(n);
|
||||
|
||||
if (n->raw_size < sizeof(struct ether_header)) {
|
||||
log_lldp("Received truncated packet, ignoring.");
|
||||
return -EBADMSG;
|
||||
}
|
||||
if (n->raw_size < sizeof(struct ether_header))
|
||||
return log_lldp_errno(n->lldp, SYNTHETIC_ERRNO(EBADMSG),
|
||||
"Received truncated packet, ignoring.");
|
||||
|
||||
memcpy(&h, LLDP_NEIGHBOR_RAW(n), sizeof(h));
|
||||
|
||||
if (h.ether_type != htobe16(ETHERTYPE_LLDP)) {
|
||||
log_lldp("Received packet with wrong type, ignoring.");
|
||||
return -EBADMSG;
|
||||
}
|
||||
if (h.ether_type != htobe16(ETHERTYPE_LLDP))
|
||||
return log_lldp_errno(n->lldp, SYNTHETIC_ERRNO(EBADMSG),
|
||||
"Received packet with wrong type, ignoring.");
|
||||
|
||||
if (h.ether_dhost[0] != 0x01 ||
|
||||
h.ether_dhost[1] != 0x80 ||
|
||||
h.ether_dhost[2] != 0xc2 ||
|
||||
h.ether_dhost[3] != 0x00 ||
|
||||
h.ether_dhost[4] != 0x00 ||
|
||||
!IN_SET(h.ether_dhost[5], 0x00, 0x03, 0x0e)) {
|
||||
log_lldp("Received packet with wrong destination address, ignoring.");
|
||||
return -EBADMSG;
|
||||
}
|
||||
!IN_SET(h.ether_dhost[5], 0x00, 0x03, 0x0e))
|
||||
return log_lldp_errno(n->lldp, SYNTHETIC_ERRNO(EBADMSG),
|
||||
"Received packet with wrong destination address, ignoring.");
|
||||
|
||||
memcpy(&n->source_address, h.ether_shost, sizeof(struct ether_addr));
|
||||
memcpy(&n->destination_address, h.ether_dhost, sizeof(struct ether_addr));
|
||||
@ -188,27 +185,24 @@ int lldp_neighbor_parse(sd_lldp_neighbor *n) {
|
||||
uint8_t type;
|
||||
uint16_t length;
|
||||
|
||||
if (left < 2) {
|
||||
log_lldp("TLV lacks header, ignoring.");
|
||||
return -EBADMSG;
|
||||
}
|
||||
if (left < 2)
|
||||
return log_lldp_errno(n->lldp, SYNTHETIC_ERRNO(EBADMSG),
|
||||
"TLV lacks header, ignoring.");
|
||||
|
||||
type = p[0] >> 1;
|
||||
length = p[1] + (((uint16_t) (p[0] & 1)) << 8);
|
||||
p += 2, left -= 2;
|
||||
|
||||
if (left < length) {
|
||||
log_lldp("TLV truncated, ignoring datagram.");
|
||||
return -EBADMSG;
|
||||
}
|
||||
if (left < length)
|
||||
return log_lldp_errno(n->lldp, SYNTHETIC_ERRNO(EBADMSG),
|
||||
"TLV truncated, ignoring datagram.");
|
||||
|
||||
switch (type) {
|
||||
|
||||
case SD_LLDP_TYPE_END:
|
||||
if (length != 0) {
|
||||
log_lldp("End marker TLV not zero-sized, ignoring datagram.");
|
||||
return -EBADMSG;
|
||||
}
|
||||
if (length != 0)
|
||||
return log_lldp_errno(n->lldp, SYNTHETIC_ERRNO(EBADMSG),
|
||||
"End marker TLV not zero-sized, ignoring datagram.");
|
||||
|
||||
/* Note that after processing the SD_LLDP_TYPE_END left could still be > 0
|
||||
* as the message may contain padding (see IEEE 802.1AB-2016, sec. 8.5.12) */
|
||||
@ -216,98 +210,93 @@ int lldp_neighbor_parse(sd_lldp_neighbor *n) {
|
||||
goto end_marker;
|
||||
|
||||
case SD_LLDP_TYPE_CHASSIS_ID:
|
||||
if (length < 2 || length > 256) { /* includes the chassis subtype, hence one extra byte */
|
||||
log_lldp("Chassis ID field size out of range, ignoring datagram.");
|
||||
return -EBADMSG;
|
||||
}
|
||||
if (n->id.chassis_id) {
|
||||
log_lldp("Duplicate chassis ID field, ignoring datagram.");
|
||||
return -EBADMSG;
|
||||
}
|
||||
if (length < 2 || length > 256)
|
||||
/* includes the chassis subtype, hence one extra byte */
|
||||
return log_lldp_errno(n->lldp, SYNTHETIC_ERRNO(EBADMSG),
|
||||
"Chassis ID field size out of range, ignoring datagram.");
|
||||
|
||||
if (n->id.chassis_id)
|
||||
return log_lldp_errno(n->lldp, SYNTHETIC_ERRNO(EBADMSG),
|
||||
"Duplicate chassis ID field, ignoring datagram.");
|
||||
|
||||
n->id.chassis_id = memdup(p, length);
|
||||
if (!n->id.chassis_id)
|
||||
return -ENOMEM;
|
||||
return log_oom_debug();
|
||||
|
||||
n->id.chassis_id_size = length;
|
||||
break;
|
||||
|
||||
case SD_LLDP_TYPE_PORT_ID:
|
||||
if (length < 2 || length > 256) { /* includes the port subtype, hence one extra byte */
|
||||
log_lldp("Port ID field size out of range, ignoring datagram.");
|
||||
return -EBADMSG;
|
||||
}
|
||||
if (n->id.port_id) {
|
||||
log_lldp("Duplicate port ID field, ignoring datagram.");
|
||||
return -EBADMSG;
|
||||
}
|
||||
if (length < 2 || length > 256)
|
||||
/* includes the port subtype, hence one extra byte */
|
||||
return log_lldp_errno(n->lldp, SYNTHETIC_ERRNO(EBADMSG),
|
||||
"Port ID field size out of range, ignoring datagram.");
|
||||
|
||||
if (n->id.port_id)
|
||||
return log_lldp_errno(n->lldp, SYNTHETIC_ERRNO(EBADMSG),
|
||||
"Duplicate port ID field, ignoring datagram.");
|
||||
|
||||
n->id.port_id = memdup(p, length);
|
||||
if (!n->id.port_id)
|
||||
return -ENOMEM;
|
||||
return log_oom_debug();
|
||||
|
||||
n->id.port_id_size = length;
|
||||
break;
|
||||
|
||||
case SD_LLDP_TYPE_TTL:
|
||||
if (length != 2) {
|
||||
log_lldp("TTL field has wrong size, ignoring datagram.");
|
||||
return -EBADMSG;
|
||||
}
|
||||
if (length != 2)
|
||||
return log_lldp_errno(n->lldp, SYNTHETIC_ERRNO(EBADMSG),
|
||||
"TTL field has wrong size, ignoring datagram.");
|
||||
|
||||
if (n->has_ttl) {
|
||||
log_lldp("Duplicate TTL field, ignoring datagram.");
|
||||
return -EBADMSG;
|
||||
}
|
||||
if (n->has_ttl)
|
||||
return log_lldp_errno(n->lldp, SYNTHETIC_ERRNO(EBADMSG),
|
||||
"Duplicate TTL field, ignoring datagram.");
|
||||
|
||||
n->ttl = unaligned_read_be16(p);
|
||||
n->has_ttl = true;
|
||||
break;
|
||||
|
||||
case SD_LLDP_TYPE_PORT_DESCRIPTION:
|
||||
r = parse_string(&n->port_description, p, length);
|
||||
r = parse_string(n->lldp, &n->port_description, p, length);
|
||||
if (r < 0)
|
||||
return r;
|
||||
break;
|
||||
|
||||
case SD_LLDP_TYPE_SYSTEM_NAME:
|
||||
r = parse_string(&n->system_name, p, length);
|
||||
r = parse_string(n->lldp, &n->system_name, p, length);
|
||||
if (r < 0)
|
||||
return r;
|
||||
break;
|
||||
|
||||
case SD_LLDP_TYPE_SYSTEM_DESCRIPTION:
|
||||
r = parse_string(&n->system_description, p, length);
|
||||
r = parse_string(n->lldp, &n->system_description, p, length);
|
||||
if (r < 0)
|
||||
return r;
|
||||
break;
|
||||
|
||||
case SD_LLDP_TYPE_SYSTEM_CAPABILITIES:
|
||||
if (length != 4)
|
||||
log_lldp("System capabilities field has wrong size, ignoring.");
|
||||
else {
|
||||
n->system_capabilities = unaligned_read_be16(p);
|
||||
n->enabled_capabilities = unaligned_read_be16(p + 2);
|
||||
n->has_capabilities = true;
|
||||
}
|
||||
return log_lldp_errno(n->lldp, SYNTHETIC_ERRNO(EBADMSG),
|
||||
"System capabilities field has wrong size.");
|
||||
|
||||
n->system_capabilities = unaligned_read_be16(p);
|
||||
n->enabled_capabilities = unaligned_read_be16(p + 2);
|
||||
n->has_capabilities = true;
|
||||
break;
|
||||
|
||||
case SD_LLDP_TYPE_PRIVATE: {
|
||||
case SD_LLDP_TYPE_PRIVATE:
|
||||
if (length < 4)
|
||||
log_lldp("Found private TLV that is too short, ignoring.");
|
||||
else {
|
||||
/* RFC 8520: MUD URL */
|
||||
if (memcmp(p, SD_LLDP_OUI_MUD, sizeof(SD_LLDP_OUI_MUD)) == 0 &&
|
||||
p[sizeof(SD_LLDP_OUI_MUD)] == SD_LLDP_OUI_SUBTYPE_MUD_USAGE_DESCRIPTION) {
|
||||
r = parse_string(&n->mud_url, p + sizeof(SD_LLDP_OUI_MUD) + 1,
|
||||
length - 1 - sizeof(SD_LLDP_OUI_MUD));
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
}
|
||||
}
|
||||
return log_lldp_errno(n->lldp, SYNTHETIC_ERRNO(EBADMSG),
|
||||
"Found private TLV that is too short, ignoring.");
|
||||
|
||||
/* RFC 8520: MUD URL */
|
||||
if (memcmp(p, SD_LLDP_OUI_MUD, sizeof(SD_LLDP_OUI_MUD)) == 0 &&
|
||||
p[sizeof(SD_LLDP_OUI_MUD)] == SD_LLDP_OUI_SUBTYPE_MUD_USAGE_DESCRIPTION) {
|
||||
r = parse_string(n->lldp, &n->mud_url, p + sizeof(SD_LLDP_OUI_MUD) + 1,
|
||||
length - 1 - sizeof(SD_LLDP_OUI_MUD));
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@ -315,11 +304,9 @@ int lldp_neighbor_parse(sd_lldp_neighbor *n) {
|
||||
}
|
||||
|
||||
end_marker:
|
||||
if (!n->id.chassis_id || !n->id.port_id || !n->has_ttl) {
|
||||
log_lldp("One or more mandatory TLV missing in datagram. Ignoring.");
|
||||
return -EBADMSG;
|
||||
|
||||
}
|
||||
if (!n->id.chassis_id || !n->id.port_id || !n->has_ttl)
|
||||
return log_lldp_errno(n->lldp, SYNTHETIC_ERRNO(EBADMSG),
|
||||
"One or more mandatory TLV missing in datagram. Ignoring.");
|
||||
|
||||
n->rindex = sizeof(struct ether_header);
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
#include "sd-ndisc.h"
|
||||
|
||||
#include "log.h"
|
||||
#include "log-link.h"
|
||||
#include "time-util.h"
|
||||
|
||||
#define NDISC_ROUTER_SOLICITATION_INTERVAL (4U * USEC_PER_SEC)
|
||||
@ -38,8 +38,18 @@ struct sd_ndisc {
|
||||
void *userdata;
|
||||
};
|
||||
|
||||
#define log_ndisc_errno(error, fmt, ...) log_internal(LOG_DEBUG, error, PROJECT_FILE, __LINE__, __func__, "NDISC: " fmt, ##__VA_ARGS__)
|
||||
#define log_ndisc(fmt, ...) log_ndisc_errno(0, fmt, ##__VA_ARGS__)
|
||||
|
||||
const char* ndisc_event_to_string(sd_ndisc_event_t e) _const_;
|
||||
sd_ndisc_event_t ndisc_event_from_string(const char *s) _pure_;
|
||||
|
||||
#define log_ndisc_errno(ndisc, error, fmt, ...) \
|
||||
({ \
|
||||
int _e = (error); \
|
||||
if (DEBUG_LOGGING) \
|
||||
log_interface_full_errno( \
|
||||
sd_ndisc_get_ifname(ndisc), \
|
||||
LOG_DEBUG, _e, "NDISC: " fmt, \
|
||||
##__VA_ARGS__); \
|
||||
-ERRNO_VALUE(_e); \
|
||||
})
|
||||
#define log_ndisc(ndisc, fmt, ...) \
|
||||
log_ndisc_errno(ndisc, 0, fmt, ##__VA_ARGS__)
|
||||
|
@ -43,7 +43,7 @@ _public_ int sd_ndisc_router_from_raw(sd_ndisc_router **ret, const void *raw, si
|
||||
return -ENOMEM;
|
||||
|
||||
memcpy(NDISC_ROUTER_RAW(rt), raw, raw_size);
|
||||
r = ndisc_router_parse(rt);
|
||||
r = ndisc_router_parse(NULL, rt);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
@ -87,7 +87,7 @@ _public_ int sd_ndisc_router_get_raw(sd_ndisc_router *rt, const void **ret, size
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ndisc_router_parse(sd_ndisc_router *rt) {
|
||||
int ndisc_router_parse(sd_ndisc *nd, sd_ndisc_router *rt) {
|
||||
struct nd_router_advert *a;
|
||||
const uint8_t *p;
|
||||
bool has_mtu = false, has_flag_extension = false;
|
||||
@ -95,23 +95,20 @@ int ndisc_router_parse(sd_ndisc_router *rt) {
|
||||
|
||||
assert(rt);
|
||||
|
||||
if (rt->raw_size < sizeof(struct nd_router_advert)) {
|
||||
log_ndisc("Too small to be a router advertisement, ignoring.");
|
||||
return -EBADMSG;
|
||||
}
|
||||
if (rt->raw_size < sizeof(struct nd_router_advert))
|
||||
return log_ndisc_errno(nd, SYNTHETIC_ERRNO(EBADMSG),
|
||||
"Too small to be a router advertisement, ignoring.");
|
||||
|
||||
/* Router advertisement packets are neatly aligned to 64bit boundaries, hence we can access them directly */
|
||||
a = NDISC_ROUTER_RAW(rt);
|
||||
|
||||
if (a->nd_ra_type != ND_ROUTER_ADVERT) {
|
||||
log_ndisc("Received ND packet that is not a router advertisement, ignoring.");
|
||||
return -EBADMSG;
|
||||
}
|
||||
if (a->nd_ra_type != ND_ROUTER_ADVERT)
|
||||
return log_ndisc_errno(nd, SYNTHETIC_ERRNO(EBADMSG),
|
||||
"Received ND packet that is not a router advertisement, ignoring.");
|
||||
|
||||
if (a->nd_ra_code != 0) {
|
||||
log_ndisc("Received ND packet with wrong RA code, ignoring.");
|
||||
return -EBADMSG;
|
||||
}
|
||||
if (a->nd_ra_code != 0)
|
||||
return log_ndisc_errno(nd, SYNTHETIC_ERRNO(EBADMSG),
|
||||
"Received ND packet with wrong RA code, ignoring.");
|
||||
|
||||
rt->hop_limit = a->nd_ra_curhoplimit;
|
||||
rt->flags = a->nd_ra_flags_reserved; /* the first 8bit */
|
||||
@ -131,36 +128,31 @@ int ndisc_router_parse(sd_ndisc_router *rt) {
|
||||
if (left == 0)
|
||||
break;
|
||||
|
||||
if (left < 2) {
|
||||
log_ndisc("Option lacks header, ignoring datagram.");
|
||||
return -EBADMSG;
|
||||
}
|
||||
if (left < 2)
|
||||
return log_ndisc_errno(nd, SYNTHETIC_ERRNO(EBADMSG),
|
||||
"Option lacks header, ignoring datagram.");
|
||||
|
||||
type = p[0];
|
||||
length = p[1] * 8;
|
||||
|
||||
if (length == 0) {
|
||||
log_ndisc("Zero-length option, ignoring datagram.");
|
||||
return -EBADMSG;
|
||||
}
|
||||
if (left < length) {
|
||||
log_ndisc("Option truncated, ignoring datagram.");
|
||||
return -EBADMSG;
|
||||
}
|
||||
if (length == 0)
|
||||
return log_ndisc_errno(nd, SYNTHETIC_ERRNO(EBADMSG),
|
||||
"Zero-length option, ignoring datagram.");
|
||||
if (left < length)
|
||||
return log_ndisc_errno(nd, SYNTHETIC_ERRNO(EBADMSG),
|
||||
"Option truncated, ignoring datagram.");
|
||||
|
||||
switch (type) {
|
||||
|
||||
case SD_NDISC_OPTION_PREFIX_INFORMATION:
|
||||
|
||||
if (length != 4*8) {
|
||||
log_ndisc("Prefix option of invalid size, ignoring datagram.");
|
||||
return -EBADMSG;
|
||||
}
|
||||
if (length != 4*8)
|
||||
return log_ndisc_errno(nd, SYNTHETIC_ERRNO(EBADMSG),
|
||||
"Prefix option of invalid size, ignoring datagram.");
|
||||
|
||||
if (p[2] > 128) {
|
||||
log_ndisc("Bad prefix length, ignoring datagram.");
|
||||
return -EBADMSG;
|
||||
}
|
||||
if (p[2] > 128)
|
||||
return log_ndisc_errno(nd, SYNTHETIC_ERRNO(EBADMSG),
|
||||
"Bad prefix length, ignoring datagram.");
|
||||
|
||||
break;
|
||||
|
||||
@ -168,14 +160,13 @@ int ndisc_router_parse(sd_ndisc_router *rt) {
|
||||
uint32_t m;
|
||||
|
||||
if (has_mtu) {
|
||||
log_ndisc("MTU option specified twice, ignoring.");
|
||||
log_ndisc(nd, "MTU option specified twice, ignoring.");
|
||||
break;
|
||||
}
|
||||
|
||||
if (length != 8) {
|
||||
log_ndisc("MTU option of invalid size, ignoring datagram.");
|
||||
return -EBADMSG;
|
||||
}
|
||||
if (length != 8)
|
||||
return log_ndisc_errno(nd, SYNTHETIC_ERRNO(EBADMSG),
|
||||
"MTU option of invalid size, ignoring datagram.");
|
||||
|
||||
m = be32toh(*(uint32_t*) (p + 4));
|
||||
if (m >= IPV6_MIN_MTU) /* ignore invalidly small MTUs */
|
||||
@ -186,37 +177,32 @@ int ndisc_router_parse(sd_ndisc_router *rt) {
|
||||
}
|
||||
|
||||
case SD_NDISC_OPTION_ROUTE_INFORMATION:
|
||||
if (length < 1*8 || length > 3*8) {
|
||||
log_ndisc("Route information option of invalid size, ignoring datagram.");
|
||||
return -EBADMSG;
|
||||
}
|
||||
if (length < 1*8 || length > 3*8)
|
||||
return log_ndisc_errno(nd, SYNTHETIC_ERRNO(EBADMSG),
|
||||
"Route information option of invalid size, ignoring datagram.");
|
||||
|
||||
if (p[2] > 128) {
|
||||
log_ndisc("Bad route prefix length, ignoring datagram.");
|
||||
return -EBADMSG;
|
||||
}
|
||||
if (p[2] > 128)
|
||||
return log_ndisc_errno(nd, SYNTHETIC_ERRNO(EBADMSG),
|
||||
"Bad route prefix length, ignoring datagram.");
|
||||
|
||||
break;
|
||||
|
||||
case SD_NDISC_OPTION_RDNSS:
|
||||
if (length < 3*8 || (length % (2*8)) != 1*8) {
|
||||
log_ndisc("RDNSS option has invalid size.");
|
||||
return -EBADMSG;
|
||||
}
|
||||
if (length < 3*8 || (length % (2*8)) != 1*8)
|
||||
return log_ndisc_errno(nd, SYNTHETIC_ERRNO(EBADMSG), "RDNSS option has invalid size.");
|
||||
|
||||
break;
|
||||
|
||||
case SD_NDISC_OPTION_FLAGS_EXTENSION:
|
||||
|
||||
if (has_flag_extension) {
|
||||
log_ndisc("Flags extension option specified twice, ignoring.");
|
||||
log_ndisc(nd, "Flags extension option specified twice, ignoring.");
|
||||
break;
|
||||
}
|
||||
|
||||
if (length < 1*8) {
|
||||
log_ndisc("Flags extension option has invalid size.");
|
||||
return -EBADMSG;
|
||||
}
|
||||
if (length < 1*8)
|
||||
return log_ndisc_errno(nd, SYNTHETIC_ERRNO(EBADMSG),
|
||||
"Flags extension option has invalid size.");
|
||||
|
||||
/* Add in the additional flags bits */
|
||||
rt->flags |=
|
||||
@ -231,10 +217,9 @@ int ndisc_router_parse(sd_ndisc_router *rt) {
|
||||
break;
|
||||
|
||||
case SD_NDISC_OPTION_DNSSL:
|
||||
if (length < 2*8) {
|
||||
log_ndisc("DNSSL option has invalid size.");
|
||||
return -EBADMSG;
|
||||
}
|
||||
if (length < 2*8)
|
||||
return log_ndisc_errno(nd, SYNTHETIC_ERRNO(EBADMSG),
|
||||
"DNSSL option has invalid size.");
|
||||
|
||||
break;
|
||||
}
|
||||
@ -437,7 +422,7 @@ _public_ int sd_ndisc_router_prefix_get_flags(sd_ndisc_router *rt, uint8_t *ret)
|
||||
flags = pi->nd_opt_pi_flags_reserved;
|
||||
|
||||
if ((flags & ND_OPT_PI_FLAG_AUTO) && (pi->nd_opt_pi_prefix_len != 64)) {
|
||||
log_ndisc("Invalid prefix length, ignoring prefix for stateless autoconfiguration.");
|
||||
log_ndisc(NULL, "Invalid prefix length, ignoring prefix for stateless autoconfiguration.");
|
||||
flags &= ~ND_OPT_PI_FLAG_AUTO;
|
||||
}
|
||||
|
||||
|
@ -45,4 +45,4 @@ static inline size_t NDISC_ROUTER_OPTION_LENGTH(const sd_ndisc_router *rt) {
|
||||
}
|
||||
|
||||
sd_ndisc_router *ndisc_router_new(size_t raw_size);
|
||||
int ndisc_router_parse(sd_ndisc_router *rt);
|
||||
int ndisc_router_parse(sd_ndisc *nd, sd_ndisc_router *rt);
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
#include "sd-radv.h"
|
||||
|
||||
#include "log.h"
|
||||
#include "log-link.h"
|
||||
#include "list.h"
|
||||
#include "sparse-endian.h"
|
||||
|
||||
@ -125,6 +125,15 @@ struct sd_radv_route_prefix {
|
||||
LIST_FIELDS(struct sd_radv_route_prefix, prefix);
|
||||
};
|
||||
|
||||
#define log_radv_full(level, error, fmt, ...) log_internal(level, error, PROJECT_FILE, __LINE__, __func__, "RADV: " fmt, ##__VA_ARGS__)
|
||||
#define log_radv_errno(error, fmt, ...) log_radv_full(LOG_DEBUG, error, fmt, ##__VA_ARGS__)
|
||||
#define log_radv(fmt, ...) log_radv_errno(0, fmt, ##__VA_ARGS__)
|
||||
#define log_radv_errno(radv, error, fmt, ...) \
|
||||
({ \
|
||||
int _e = (error); \
|
||||
if (DEBUG_LOGGING) \
|
||||
log_interface_full_errno( \
|
||||
sd_radv_get_ifname(radv), \
|
||||
LOG_DEBUG, _e, "RADV: " fmt, \
|
||||
##__VA_ARGS__); \
|
||||
-ERRNO_VALUE(_e); \
|
||||
})
|
||||
#define log_radv(radv, fmt, ...) \
|
||||
log_radv_errno(radv, 0, fmt, ##__VA_ARGS__)
|
||||
|
@ -1191,7 +1191,7 @@ static int client_parse_message(
|
||||
break;
|
||||
}
|
||||
|
||||
r = dhcp6_option_parse_ia(option, &lease->ia, &ia_na_status);
|
||||
r = dhcp6_option_parse_ia(client, option, &lease->ia, &ia_na_status);
|
||||
if (r < 0 && r != -ENOMSG)
|
||||
return r;
|
||||
|
||||
@ -1224,7 +1224,7 @@ static int client_parse_message(
|
||||
break;
|
||||
}
|
||||
|
||||
r = dhcp6_option_parse_ia(option, &lease->pd, &ia_pd_status);
|
||||
r = dhcp6_option_parse_ia(client, option, &lease->pd, &ia_pd_status);
|
||||
if (r < 0 && r != -ENOMSG)
|
||||
return r;
|
||||
|
||||
|
@ -206,7 +206,7 @@ int dhcp6_lease_set_dns(sd_dhcp6_lease *lease, uint8_t *optval, size_t optlen) {
|
||||
lease->dns_count,
|
||||
&lease->dns_allocated);
|
||||
if (r < 0)
|
||||
return log_dhcp6_client_errno(client, r, "Invalid DNS server option: %m");
|
||||
return r;
|
||||
|
||||
lease->dns_count = r;
|
||||
|
||||
@ -321,19 +321,16 @@ int dhcp6_lease_set_sntp(sd_dhcp6_lease *lease, uint8_t *optval, size_t optlen)
|
||||
if (!optlen)
|
||||
return 0;
|
||||
|
||||
if (lease->ntp || lease->ntp_fqdn) {
|
||||
log_dhcp6_client(client, "NTP information already provided");
|
||||
if (lease->ntp || lease->ntp_fqdn)
|
||||
return -EEXIST;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
log_dhcp6_client(client, "Using deprecated SNTP information");
|
||||
/* Using deprecated SNTP information */
|
||||
|
||||
r = dhcp6_option_parse_ip6addrs(optval, optlen, &lease->ntp,
|
||||
lease->ntp_count,
|
||||
&lease->ntp_allocated);
|
||||
if (r < 0)
|
||||
return log_dhcp6_client_errno(client, r, "Invalid SNTP server option: %m");
|
||||
return r;
|
||||
|
||||
lease->ntp_count = r;
|
||||
|
||||
|
@ -76,7 +76,15 @@ struct sd_ipv4acd {
|
||||
};
|
||||
|
||||
#define log_ipv4acd_errno(acd, error, fmt, ...) \
|
||||
log_interface_full_errno(sd_ipv4acd_get_ifname(acd), LOG_DEBUG, error, "IPV4ACD: " fmt, ##__VA_ARGS__)
|
||||
({ \
|
||||
int _e = (error); \
|
||||
if (DEBUG_LOGGING) \
|
||||
log_interface_full_errno( \
|
||||
sd_ipv4acd_get_ifname(acd), \
|
||||
LOG_DEBUG, _e, "IPv4ACD: " fmt, \
|
||||
##__VA_ARGS__); \
|
||||
-ERRNO_VALUE(_e); \
|
||||
})
|
||||
#define log_ipv4acd(acd, fmt, ...) \
|
||||
log_ipv4acd_errno(acd, 0, fmt, ##__VA_ARGS__)
|
||||
|
||||
|
@ -50,7 +50,15 @@ struct sd_ipv4ll {
|
||||
};
|
||||
|
||||
#define log_ipv4ll_errno(ll, error, fmt, ...) \
|
||||
log_interface_full_errno(sd_ipv4ll_get_ifname(ll), LOG_DEBUG, error, "IPV4LL: " fmt, ##__VA_ARGS__)
|
||||
({ \
|
||||
int _e = (error); \
|
||||
if (DEBUG_LOGGING) \
|
||||
log_interface_full_errno( \
|
||||
sd_ipv4ll_get_ifname(ll), \
|
||||
LOG_DEBUG, _e, "IPv4LL: " fmt, \
|
||||
##__VA_ARGS__); \
|
||||
-ERRNO_VALUE(_e); \
|
||||
})
|
||||
#define log_ipv4ll(ll, fmt, ...) \
|
||||
log_ipv4ll_errno(ll, 0, fmt, ##__VA_ARGS__)
|
||||
|
||||
|
@ -40,12 +40,10 @@ static void lldp_callback(sd_lldp *lldp, sd_lldp_event_t event, sd_lldp_neighbor
|
||||
assert(lldp);
|
||||
assert(event >= 0 && event < _SD_LLDP_EVENT_MAX);
|
||||
|
||||
if (!lldp->callback) {
|
||||
log_lldp("Received '%s' event.", lldp_event_to_string(event));
|
||||
return;
|
||||
}
|
||||
if (!lldp->callback)
|
||||
return (void) log_lldp(lldp, "Received '%s' event.", lldp_event_to_string(event));
|
||||
|
||||
log_lldp("Invoking callback for '%s' event.", lldp_event_to_string(event));
|
||||
log_lldp(lldp, "Invoking callback for '%s' event.", lldp_event_to_string(event));
|
||||
lldp->callback(lldp, event, n, lldp->userdata);
|
||||
}
|
||||
|
||||
@ -187,11 +185,11 @@ static int lldp_handle_datagram(sd_lldp *lldp, sd_lldp_neighbor *n) {
|
||||
|
||||
r = lldp_add_neighbor(lldp, n);
|
||||
if (r < 0) {
|
||||
log_lldp_errno(r, "Failed to add datagram. Ignoring.");
|
||||
log_lldp_errno(lldp, r, "Failed to add datagram. Ignoring.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
log_lldp("Successfully processed LLDP datagram.");
|
||||
log_lldp(lldp, "Successfully processed LLDP datagram.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -205,8 +203,10 @@ static int lldp_receive_datagram(sd_event_source *s, int fd, uint32_t revents, v
|
||||
assert(lldp);
|
||||
|
||||
space = next_datagram_size_fd(fd);
|
||||
if (space < 0)
|
||||
return log_lldp_errno(space, "Failed to determine datagram size to read: %m");
|
||||
if (space < 0) {
|
||||
log_lldp_errno(lldp, space, "Failed to determine datagram size to read, ignoring: %m");
|
||||
return 0;
|
||||
}
|
||||
|
||||
n = lldp_neighbor_new(space);
|
||||
if (!n)
|
||||
@ -217,12 +217,13 @@ static int lldp_receive_datagram(sd_event_source *s, int fd, uint32_t revents, v
|
||||
if (IN_SET(errno, EAGAIN, EINTR))
|
||||
return 0;
|
||||
|
||||
return log_lldp_errno(errno, "Failed to read LLDP datagram: %m");
|
||||
log_lldp_errno(lldp, errno, "Failed to read LLDP datagram, ignoring: %m");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ((size_t) length != n->raw_size) {
|
||||
log_lldp("Packet size mismatch.");
|
||||
return -EINVAL;
|
||||
log_lldp(lldp, "Packet size mismatch, ignoring");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Try to get the timestamp of this packet if it is known */
|
||||
@ -268,7 +269,7 @@ _public_ int sd_lldp_start(sd_lldp *lldp) {
|
||||
|
||||
(void) sd_event_source_set_description(lldp->io_event_source, "lldp-io");
|
||||
|
||||
log_lldp("Started LLDP client");
|
||||
log_lldp(lldp, "Started LLDP client");
|
||||
return 1;
|
||||
|
||||
fail:
|
||||
@ -283,7 +284,7 @@ _public_ int sd_lldp_stop(sd_lldp *lldp) {
|
||||
if (lldp->fd < 0)
|
||||
return 0;
|
||||
|
||||
log_lldp("Stopping LLDP client");
|
||||
log_lldp(lldp, "Stopping LLDP client");
|
||||
|
||||
lldp_reset(lldp);
|
||||
lldp_flush_neighbors(lldp);
|
||||
@ -417,12 +418,16 @@ static int on_timer_event(sd_event_source *s, uint64_t usec, void *userdata) {
|
||||
int r;
|
||||
|
||||
r = lldp_make_space(lldp, 0);
|
||||
if (r < 0)
|
||||
return log_lldp_errno(r, "Failed to make space: %m");
|
||||
if (r < 0) {
|
||||
log_lldp_errno(lldp, r, "Failed to make space, ignoring: %m");
|
||||
return 0;
|
||||
}
|
||||
|
||||
r = lldp_start_timer(lldp, NULL);
|
||||
if (r < 0)
|
||||
return log_lldp_errno(r, "Failed to restart timer: %m");
|
||||
if (r < 0) {
|
||||
log_lldp_errno(lldp, r, "Failed to restart timer, ignoring: %m");
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -35,12 +35,10 @@ static void ndisc_callback(sd_ndisc *ndisc, sd_ndisc_event_t event, sd_ndisc_rou
|
||||
assert(ndisc);
|
||||
assert(event >= 0 && event < _SD_NDISC_EVENT_MAX);
|
||||
|
||||
if (!ndisc->callback) {
|
||||
log_ndisc("Received '%s' event.", ndisc_event_to_string(event));
|
||||
return;
|
||||
}
|
||||
if (!ndisc->callback)
|
||||
return (void) log_ndisc(ndisc, "Received '%s' event.", ndisc_event_to_string(event));
|
||||
|
||||
log_ndisc("Invoking callback for '%s' event.", ndisc_event_to_string(event));
|
||||
log_ndisc(ndisc, "Invoking callback for '%s' event.", ndisc_event_to_string(event));
|
||||
ndisc->callback(ndisc, event, rt, ndisc->userdata);
|
||||
}
|
||||
|
||||
@ -200,7 +198,7 @@ static int ndisc_handle_datagram(sd_ndisc *nd, sd_ndisc_router *rt) {
|
||||
assert(nd);
|
||||
assert(rt);
|
||||
|
||||
r = ndisc_router_parse(rt);
|
||||
r = ndisc_router_parse(nd, rt);
|
||||
if (r == -EBADMSG) /* Bad packet */
|
||||
return 0;
|
||||
if (r < 0)
|
||||
@ -212,7 +210,7 @@ static int ndisc_handle_datagram(sd_ndisc *nd, sd_ndisc_router *rt) {
|
||||
if (rt->hop_limit > 0)
|
||||
nd->hop_limit = rt->hop_limit;
|
||||
|
||||
log_ndisc("Received Router Advertisement: flags %s preference %s lifetime %" PRIu16 " sec",
|
||||
log_ndisc(nd, "Received Router Advertisement: flags %s preference %s lifetime %" PRIu16 " sec",
|
||||
rt->flags & ND_RA_FLAG_MANAGED ? "MANAGED" : rt->flags & ND_RA_FLAG_OTHER ? "OTHER" : "none",
|
||||
rt->preference == SD_NDISC_PREFERENCE_HIGH ? "high" : rt->preference == SD_NDISC_PREFERENCE_LOW ? "low" : "medium",
|
||||
rt->lifetime);
|
||||
@ -233,8 +231,10 @@ static int ndisc_recv(sd_event_source *s, int fd, uint32_t revents, void *userda
|
||||
assert(nd->event);
|
||||
|
||||
buflen = next_datagram_size_fd(fd);
|
||||
if (buflen < 0)
|
||||
return log_ndisc_errno(buflen, "Failed to determine datagram size to read: %m");
|
||||
if (buflen < 0) {
|
||||
log_ndisc_errno(nd, buflen, "Failed to determine datagram size to read, ignoring: %m");
|
||||
return 0;
|
||||
}
|
||||
|
||||
rt = ndisc_router_new(buflen);
|
||||
if (!rt)
|
||||
@ -245,22 +245,22 @@ static int ndisc_recv(sd_event_source *s, int fd, uint32_t revents, void *userda
|
||||
switch (r) {
|
||||
case -EADDRNOTAVAIL:
|
||||
(void) in_addr_to_string(AF_INET6, (const union in_addr_union*) &rt->address, &addr);
|
||||
log_ndisc("Received RA from non-link-local address %s. Ignoring", addr);
|
||||
log_ndisc(nd, "Received RA from non-link-local address %s. Ignoring", addr);
|
||||
break;
|
||||
|
||||
case -EMULTIHOP:
|
||||
log_ndisc("Received RA with invalid hop limit. Ignoring.");
|
||||
log_ndisc(nd, "Received RA with invalid hop limit. Ignoring.");
|
||||
break;
|
||||
|
||||
case -EPFNOSUPPORT:
|
||||
log_ndisc("Received invalid source address from ICMPv6 socket. Ignoring.");
|
||||
log_ndisc(nd, "Received invalid source address from ICMPv6 socket. Ignoring.");
|
||||
break;
|
||||
|
||||
case -EAGAIN: /* ignore spurious wakeups */
|
||||
break;
|
||||
|
||||
default:
|
||||
log_ndisc_errno(r, "Unexpected error while reading from ICMPv6, ignoring: %m");
|
||||
log_ndisc_errno(nd, r, "Unexpected error while reading from ICMPv6, ignoring: %m");
|
||||
break;
|
||||
}
|
||||
|
||||
@ -309,11 +309,11 @@ static int ndisc_timeout(sd_event_source *s, uint64_t usec, void *userdata) {
|
||||
|
||||
r = icmp6_send_router_solicitation(nd->fd, &nd->mac_addr);
|
||||
if (r < 0) {
|
||||
log_ndisc_errno(r, "Error sending Router Solicitation: %m");
|
||||
log_ndisc_errno(nd, r, "Error sending Router Solicitation: %m");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
log_ndisc("Sent Router Solicitation, next solicitation in %s",
|
||||
log_ndisc(nd, "Sent Router Solicitation, next solicitation in %s",
|
||||
format_timespan(time_string, FORMAT_TIMESPAN_MAX,
|
||||
nd->retransmit_time, USEC_PER_SEC));
|
||||
|
||||
@ -330,7 +330,7 @@ static int ndisc_timeout_no_ra(sd_event_source *s, uint64_t usec, void *userdata
|
||||
assert(s);
|
||||
assert(nd);
|
||||
|
||||
log_ndisc("No RA received before link confirmation timeout");
|
||||
log_ndisc(nd, "No RA received before link confirmation timeout");
|
||||
|
||||
(void) event_source_disable(nd->timeout_no_ra);
|
||||
ndisc_callback(nd, SD_NDISC_EVENT_TIMEOUT, NULL);
|
||||
@ -345,7 +345,7 @@ _public_ int sd_ndisc_stop(sd_ndisc *nd) {
|
||||
if (nd->fd < 0)
|
||||
return 0;
|
||||
|
||||
log_ndisc("Stopping IPv6 Router Solicitation client");
|
||||
log_ndisc(nd, "Stopping IPv6 Router Solicitation client");
|
||||
|
||||
ndisc_reset(nd);
|
||||
return 1;
|
||||
@ -398,7 +398,7 @@ _public_ int sd_ndisc_start(sd_ndisc *nd) {
|
||||
if (r < 0)
|
||||
goto fail;
|
||||
|
||||
log_ndisc("Started IPv6 Router Solicitation client");
|
||||
log_ndisc(nd, "Started IPv6 Router Solicitation client");
|
||||
return 1;
|
||||
|
||||
fail:
|
||||
|
@ -247,22 +247,22 @@ static int radv_recv(sd_event_source *s, int fd, uint32_t revents, void *userdat
|
||||
switch (r) {
|
||||
case -EADDRNOTAVAIL:
|
||||
(void) in_addr_to_string(AF_INET6, (const union in_addr_union*) &src, &addr);
|
||||
log_radv("Received RS from non-link-local address %s. Ignoring", addr);
|
||||
log_radv(ra, "Received RS from non-link-local address %s. Ignoring", addr);
|
||||
break;
|
||||
|
||||
case -EMULTIHOP:
|
||||
log_radv("Received RS with invalid hop limit. Ignoring.");
|
||||
log_radv(ra, "Received RS with invalid hop limit. Ignoring.");
|
||||
break;
|
||||
|
||||
case -EPFNOSUPPORT:
|
||||
log_radv("Received invalid source address from ICMPv6 socket. Ignoring.");
|
||||
log_radv(ra, "Received invalid source address from ICMPv6 socket. Ignoring.");
|
||||
break;
|
||||
|
||||
case -EAGAIN: /* ignore spurious wakeups */
|
||||
break;
|
||||
|
||||
default:
|
||||
log_radv_errno(r, "Unexpected error receiving from ICMPv6 socket: %m");
|
||||
log_radv_errno(ra, r, "Unexpected error receiving from ICMPv6 socket, Ignoring: %m");
|
||||
break;
|
||||
}
|
||||
|
||||
@ -270,7 +270,7 @@ static int radv_recv(sd_event_source *s, int fd, uint32_t revents, void *userdat
|
||||
}
|
||||
|
||||
if ((size_t) buflen < sizeof(struct nd_router_solicit)) {
|
||||
log_radv("Too short packet received");
|
||||
log_radv(ra, "Too short packet received, ignoring");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -278,9 +278,9 @@ static int radv_recv(sd_event_source *s, int fd, uint32_t revents, void *userdat
|
||||
|
||||
r = radv_send(ra, &src, ra->lifetime);
|
||||
if (r < 0)
|
||||
log_radv_errno(r, "Unable to send solicited Router Advertisement to %s: %m", strnull(addr));
|
||||
log_radv_errno(ra, r, "Unable to send solicited Router Advertisement to %s, ignoring: %m", strnull(addr));
|
||||
else
|
||||
log_radv("Sent solicited Router Advertisement to %s", strnull(addr));
|
||||
log_radv(ra, "Sent solicited Router Advertisement to %s", strnull(addr));
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -313,7 +313,7 @@ static int radv_timeout(sd_event_source *s, uint64_t usec, void *userdata) {
|
||||
|
||||
r = radv_send(ra, NULL, ra->lifetime);
|
||||
if (r < 0)
|
||||
log_radv_errno(r, "Unable to send Router Advertisement: %m");
|
||||
log_radv_errno(ra, r, "Unable to send Router Advertisement: %m");
|
||||
|
||||
/* RFC 4861, Section 6.2.4, sending initial Router Advertisements */
|
||||
if (ra->ra_sent < SD_RADV_MAX_INITIAL_RTR_ADVERTISEMENTS) {
|
||||
@ -330,7 +330,7 @@ static int radv_timeout(sd_event_source *s, uint64_t usec, void *userdata) {
|
||||
|
||||
timeout = radv_compute_timeout(min_timeout, max_timeout);
|
||||
|
||||
log_radv("Next Router Advertisement in %s",
|
||||
log_radv(ra, "Next Router Advertisement in %s",
|
||||
format_timespan(time_string, FORMAT_TIMESPAN_MAX,
|
||||
timeout, USEC_PER_SEC));
|
||||
|
||||
@ -361,13 +361,13 @@ _public_ int sd_radv_stop(sd_radv *ra) {
|
||||
if (ra->state == SD_RADV_STATE_IDLE)
|
||||
return 0;
|
||||
|
||||
log_radv("Stopping IPv6 Router Advertisement daemon");
|
||||
log_radv(ra, "Stopping IPv6 Router Advertisement daemon");
|
||||
|
||||
/* RFC 4861, Section 6.2.5, send at least one Router Advertisement
|
||||
with zero lifetime */
|
||||
r = radv_send(ra, NULL, 0);
|
||||
if (r < 0)
|
||||
log_radv_errno(r, "Unable to send last Router Advertisement with router lifetime set to zero: %m");
|
||||
log_radv_errno(ra, r, "Unable to send last Router Advertisement with router lifetime set to zero: %m");
|
||||
|
||||
radv_reset(ra);
|
||||
ra->fd = safe_close(ra->fd);
|
||||
@ -412,7 +412,7 @@ _public_ int sd_radv_start(sd_radv *ra) {
|
||||
|
||||
ra->state = SD_RADV_STATE_ADVERTISING;
|
||||
|
||||
log_radv("Started IPv6 Router Advertisement daemon");
|
||||
log_radv(ra, "Started IPv6 Router Advertisement daemon");
|
||||
|
||||
return 0;
|
||||
|
||||
@ -581,10 +581,9 @@ _public_ int sd_radv_add_prefix(sd_radv *ra, sd_radv_prefix *p, int dynamic) {
|
||||
(void) in_addr_prefix_to_string(AF_INET6,
|
||||
(const union in_addr_union*) &cur->opt.in6_addr,
|
||||
cur->opt.prefixlen, &addr_cur);
|
||||
log_radv("IPv6 prefix %s already configured, ignoring %s",
|
||||
strna(addr_cur), strna(addr_p));
|
||||
|
||||
return -EEXIST;
|
||||
return log_radv_errno(ra, SYNTHETIC_ERRNO(EEXIST),
|
||||
"IPv6 prefix %s already configured, ignoring %s",
|
||||
strna(addr_cur), strna(addr_p));
|
||||
}
|
||||
|
||||
p = sd_radv_prefix_ref(p);
|
||||
@ -594,7 +593,7 @@ _public_ int sd_radv_add_prefix(sd_radv *ra, sd_radv_prefix *p, int dynamic) {
|
||||
ra->n_prefixes++;
|
||||
|
||||
if (!dynamic) {
|
||||
log_radv("Added prefix %s", strna(addr_p));
|
||||
log_radv(ra, "Added prefix %s", strna(addr_p));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -604,9 +603,9 @@ _public_ int sd_radv_add_prefix(sd_radv *ra, sd_radv_prefix *p, int dynamic) {
|
||||
if (ra->ra_sent > 0) {
|
||||
r = radv_send(ra, NULL, ra->lifetime);
|
||||
if (r < 0)
|
||||
log_radv_errno(r, "Unable to send Router Advertisement for added prefix: %m");
|
||||
log_radv_errno(ra, r, "Unable to send Router Advertisement for added prefix: %m");
|
||||
else
|
||||
log_radv("Sent Router Advertisement for added prefix");
|
||||
log_radv(ra, "Sent Router Advertisement for added prefix");
|
||||
}
|
||||
|
||||
update:
|
||||
@ -627,7 +626,7 @@ _public_ int sd_radv_add_prefix(sd_radv *ra, sd_radv_prefix *p, int dynamic) {
|
||||
cur->valid_until = valid_until;
|
||||
cur->preferred_until = preferred_until;
|
||||
|
||||
log_radv("Updated prefix %s preferred %s valid %s",
|
||||
log_radv(ra, "Updated prefix %s preferred %s valid %s",
|
||||
strna(addr_p),
|
||||
format_timespan(time_string_preferred, FORMAT_TIMESPAN_MAX,
|
||||
preferred, USEC_PER_SEC),
|
||||
@ -697,10 +696,9 @@ _public_ int sd_radv_add_route_prefix(sd_radv *ra, sd_radv_route_prefix *p, int
|
||||
(void) in_addr_prefix_to_string(AF_INET6,
|
||||
(const union in_addr_union*) &cur->opt.in6_addr,
|
||||
cur->opt.prefixlen, &addr);
|
||||
log_radv("IPv6 route prefix %s already configured, ignoring %s",
|
||||
strna(addr), strna(pretty));
|
||||
|
||||
return -EEXIST;
|
||||
return log_radv_errno(ra, SYNTHETIC_ERRNO(EEXIST),
|
||||
"IPv6 route prefix %s already configured, ignoring %s",
|
||||
strna(addr), strna(pretty));
|
||||
}
|
||||
|
||||
p = sd_radv_route_prefix_ref(p);
|
||||
@ -709,7 +707,7 @@ _public_ int sd_radv_add_route_prefix(sd_radv *ra, sd_radv_route_prefix *p, int
|
||||
ra->n_route_prefixes++;
|
||||
|
||||
if (!dynamic) {
|
||||
log_radv("Added prefix %s", strna(pretty));
|
||||
log_radv(ra, "Added prefix %s", strna(pretty));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -717,9 +715,9 @@ _public_ int sd_radv_add_route_prefix(sd_radv *ra, sd_radv_route_prefix *p, int
|
||||
if (ra->ra_sent > 0) {
|
||||
r = radv_send(ra, NULL, ra->lifetime);
|
||||
if (r < 0)
|
||||
log_radv_errno(r, "Unable to send Router Advertisement for added route prefix: %m");
|
||||
log_radv_errno(ra, r, "Unable to send Router Advertisement for added route prefix: %m");
|
||||
else
|
||||
log_radv("Sent Router Advertisement for added route prefix");
|
||||
log_radv(ra, "Sent Router Advertisement for added route prefix");
|
||||
}
|
||||
|
||||
update:
|
||||
@ -732,7 +730,7 @@ _public_ int sd_radv_add_route_prefix(sd_radv *ra, sd_radv_route_prefix *p, int
|
||||
if (valid_until == USEC_INFINITY)
|
||||
return -EOVERFLOW;
|
||||
|
||||
log_radv("Updated route prefix %s valid %s",
|
||||
log_radv(ra, "Updated route prefix %s valid %s",
|
||||
strna(pretty),
|
||||
format_timespan(time_string_valid, FORMAT_TIMESPAN_MAX, valid, USEC_PER_SEC));
|
||||
|
||||
@ -861,7 +859,7 @@ _public_ int sd_radv_prefix_set_prefix(sd_radv_prefix *p, const struct in6_addr
|
||||
|
||||
if (prefixlen > 64)
|
||||
/* unusual but allowed, log it */
|
||||
log_radv("Unusual prefix length %d greater than 64", prefixlen);
|
||||
log_radv(NULL, "Unusual prefix length %d greater than 64", prefixlen);
|
||||
|
||||
p->opt.in6_addr = *in6_addr;
|
||||
p->opt.prefixlen = prefixlen;
|
||||
@ -951,7 +949,7 @@ _public_ int sd_radv_prefix_set_route_prefix(sd_radv_route_prefix *p, const stru
|
||||
|
||||
if (prefixlen > 64)
|
||||
/* unusual but allowed, log it */
|
||||
log_radv("Unusual prefix length %u greater than 64", prefixlen);
|
||||
log_radv(NULL, "Unusual prefix length %u greater than 64", prefixlen);
|
||||
|
||||
p->opt.in6_addr = *in6_addr;
|
||||
p->opt.prefixlen = prefixlen;
|
||||
|
@ -295,17 +295,17 @@ static int test_option_status(sd_event *e) {
|
||||
option = (DHCP6Option *)option1;
|
||||
assert_se(sizeof(option1) == sizeof(DHCP6Option) + be16toh(option->len));
|
||||
|
||||
r = dhcp6_option_parse_ia(option, &ia, NULL);
|
||||
r = dhcp6_option_parse_ia(NULL, option, &ia, NULL);
|
||||
assert_se(r == 0);
|
||||
assert_se(ia.addresses == NULL);
|
||||
|
||||
option->len = htobe16(17);
|
||||
r = dhcp6_option_parse_ia(option, &ia, NULL);
|
||||
r = dhcp6_option_parse_ia(NULL, option, &ia, NULL);
|
||||
assert_se(r == -ENOBUFS);
|
||||
assert_se(ia.addresses == NULL);
|
||||
|
||||
option->len = htobe16(sizeof(DHCP6Option));
|
||||
r = dhcp6_option_parse_ia(option, &ia, NULL);
|
||||
r = dhcp6_option_parse_ia(NULL, option, &ia, NULL);
|
||||
assert_se(r == -ENOBUFS);
|
||||
assert_se(ia.addresses == NULL);
|
||||
|
||||
@ -313,7 +313,7 @@ static int test_option_status(sd_event *e) {
|
||||
option = (DHCP6Option *)option2;
|
||||
assert_se(sizeof(option2) == sizeof(DHCP6Option) + be16toh(option->len));
|
||||
|
||||
r = dhcp6_option_parse_ia(option, &ia, NULL);
|
||||
r = dhcp6_option_parse_ia(NULL, option, &ia, NULL);
|
||||
assert_se(r >= 0);
|
||||
assert_se(ia.addresses == NULL);
|
||||
|
||||
@ -321,7 +321,7 @@ static int test_option_status(sd_event *e) {
|
||||
option = (DHCP6Option *)option3;
|
||||
assert_se(sizeof(option3) == sizeof(DHCP6Option) + be16toh(option->len));
|
||||
|
||||
r = dhcp6_option_parse_ia(option, &ia, NULL);
|
||||
r = dhcp6_option_parse_ia(NULL, option, &ia, NULL);
|
||||
assert_se(r >= 0);
|
||||
assert_se(ia.addresses != NULL);
|
||||
dhcp6_lease_free_ia(&ia);
|
||||
@ -330,7 +330,7 @@ static int test_option_status(sd_event *e) {
|
||||
option = (DHCP6Option *)option4;
|
||||
assert_se(sizeof(option4) == sizeof(DHCP6Option) + be16toh(option->len));
|
||||
|
||||
r = dhcp6_option_parse_ia(option, &pd, NULL);
|
||||
r = dhcp6_option_parse_ia(NULL, option, &pd, NULL);
|
||||
assert_se(r >= 0);
|
||||
assert_se(pd.addresses != NULL);
|
||||
assert_se(memcmp(&pd.ia_pd.id, &option4[4], 4) == 0);
|
||||
@ -342,7 +342,7 @@ static int test_option_status(sd_event *e) {
|
||||
option = (DHCP6Option *)option5;
|
||||
assert_se(sizeof(option5) == sizeof(DHCP6Option) + be16toh(option->len));
|
||||
|
||||
r = dhcp6_option_parse_ia(option, &pd, NULL);
|
||||
r = dhcp6_option_parse_ia(NULL, option, &pd, NULL);
|
||||
assert_se(r >= 0);
|
||||
assert_se(pd.addresses != NULL);
|
||||
dhcp6_lease_free_ia(&pd);
|
||||
@ -460,7 +460,7 @@ static int test_advertise_option(sd_event *e) {
|
||||
val = htobe32(120);
|
||||
assert_se(!memcmp(optval + 8, &val, sizeof(val)));
|
||||
|
||||
assert_se(dhcp6_option_parse_ia(option, &lease->ia, NULL) >= 0);
|
||||
assert_se(dhcp6_option_parse_ia(NULL, option, &lease->ia, NULL) >= 0);
|
||||
|
||||
break;
|
||||
|
||||
@ -656,7 +656,7 @@ static int test_client_verify_request(DHCP6Message *request, size_t len) {
|
||||
assert_se(!memcmp(optval + 8, &val, sizeof(val)));
|
||||
|
||||
/* Then, this should refuse all addresses. */
|
||||
assert_se(dhcp6_option_parse_ia(option, &lease->ia, NULL) >= 0);
|
||||
assert_se(dhcp6_option_parse_ia(NULL, option, &lease->ia, NULL) >= 0);
|
||||
|
||||
break;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user