1
1
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:
Yu Watanabe 2021-02-24 18:18:35 +09:00
parent 61a9fa8f0c
commit 353887831b
18 changed files with 342 additions and 302 deletions

View File

@ -12,6 +12,7 @@
#include "sd-dhcp-client.h" #include "sd-dhcp-client.h"
#include "dhcp-protocol.h" #include "dhcp-protocol.h"
#include "log-link.h"
#include "socket-util.h" #include "socket-util.h"
typedef struct sd_dhcp_option { 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) \ #define DHCP_CLIENT_DONT_DESTROY(client) \
_cleanup_(sd_dhcp_client_unrefp) _unused_ sd_dhcp_client *_dont_destroy_##client = sd_dhcp_client_ref(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_errno(client, error, fmt, ...) \
#define log_dhcp_client(client, fmt, ...) log_dhcp_client_errno(client, 0, fmt, ##__VA_ARGS__) ({ \
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__)

View File

@ -10,7 +10,7 @@
#include "dhcp-internal.h" #include "dhcp-internal.h"
#include "ordered-set.h" #include "ordered-set.h"
#include "log.h" #include "log-link.h"
#include "time-util.h" #include "time-util.h"
typedef enum DHCPRawOption { typedef enum DHCPRawOption {
@ -86,9 +86,6 @@ typedef struct DHCPRequest {
uint32_t lifetime; uint32_t lifetime;
} DHCPRequest; } 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, int dhcp_server_handle_message(sd_dhcp_server *server, DHCPMessage *message,
size_t length); size_t length);
int dhcp_server_send_packet(sd_dhcp_server *server, 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); void client_id_hash_func(const DHCPClientId *p, struct siphash *state);
int client_id_compare_func(const DHCPClientId *a, const DHCPClientId *b); 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__)

View File

@ -9,9 +9,11 @@
#include <netinet/in.h> #include <netinet/in.h>
#include "sd-event.h" #include "sd-event.h"
#include "sd-dhcp6-client.h"
#include "list.h"
#include "hashmap.h" #include "hashmap.h"
#include "list.h"
#include "log-link.h"
#include "macro.h" #include "macro.h"
#include "sparse-endian.h" #include "sparse-endian.h"
@ -78,7 +80,7 @@ struct ia_ta {
be32_t id; be32_t id;
} _packed_; } _packed_;
struct DHCP6IA { typedef struct DHCP6IA {
uint16_t type; uint16_t type;
union { union {
struct ia_na ia_na; struct ia_na ia_na;
@ -87,12 +89,7 @@ struct DHCP6IA {
}; };
LIST_HEAD(DHCP6Address, addresses); LIST_HEAD(DHCP6Address, addresses);
}; } DHCP6IA;
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__)
int dhcp6_option_append(uint8_t **buf, size_t *buflen, uint16_t code, int dhcp6_option_append(uint8_t **buf, size_t *buflen, uint16_t code,
size_t optlen, const void *optval); 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, int dhcp6_option_parse(uint8_t **buf, size_t *buflen, uint16_t *optcode,
size_t *optlen, uint8_t **optvalue); size_t *optlen, uint8_t **optvalue);
int dhcp6_option_parse_status(DHCP6Option *option, size_t len); 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, int dhcp6_option_parse_ip6addrs(uint8_t *optval, uint16_t optlen,
struct in6_addr **addrs, size_t count, struct in6_addr **addrs, size_t count,
size_t *allocated); 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_; int dhcp6_message_type_from_string(const char *s) _pure_;
const char *dhcp6_message_status_to_string(int s) _const_; const char *dhcp6_message_status_to_string(int s) _const_;
int dhcp6_message_status_from_string(const char *s) _pure_; 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__)

View File

@ -425,7 +425,7 @@ int dhcp6_option_parse_status(DHCP6Option *option, size_t len) {
return be16toh(statusopt->status); 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; DHCP6AddressOption *addr_option = (DHCP6AddressOption *)option;
DHCP6Address *addr; DHCP6Address *addr;
uint32_t lt_valid, lt_pref; 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_valid = be32toh(addr_option->iaaddr.lifetime_valid);
lt_pref = be32toh(addr_option->iaaddr.lifetime_preferred); lt_pref = be32toh(addr_option->iaaddr.lifetime_preferred);
if (lt_valid == 0 || lt_pref > lt_valid) { if (lt_valid == 0 || lt_pref > lt_valid)
log_dhcp6_client(client, return log_dhcp6_client_errno(client, SYNTHETIC_ERRNO(EINVAL),
"Valid lifetime of an IA address is zero or " "Valid lifetime of an IA address is zero or "
"preferred lifetime %"PRIu32" > valid lifetime %"PRIu32, "preferred lifetime %"PRIu32" > valid lifetime %"PRIu32,
lt_pref, lt_valid); lt_pref, lt_valid);
return -EINVAL;
}
if (be16toh(option->len) + offsetof(DHCP6Option, data) > sizeof(*addr_option)) { 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)); r = dhcp6_option_parse_status((DHCP6Option *)addr_option->options, be16toh(option->len) + offsetof(DHCP6Option, data) - sizeof(*addr_option));
if (r < 0) if (r < 0)
return r; return r;
if (r > 0) { if (r > 0)
log_dhcp6_client(client, "Non-zero status code '%s' for address is received", return log_dhcp6_client_errno(client, SYNTHETIC_ERRNO(EINVAL),
dhcp6_message_status_to_string(r)); "Non-zero status code '%s' for address is received",
return -EINVAL; dhcp6_message_status_to_string(r));
}
} }
addr = new0(DHCP6Address, 1); addr = new0(DHCP6Address, 1);
@ -470,7 +467,7 @@ static int dhcp6_option_parse_address(DHCP6Option *option, DHCP6IA *ia, uint32_t
return 0; 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; DHCP6PDPrefixOption *pdprefix_option = (DHCP6PDPrefixOption *)option;
DHCP6Address *prefix; DHCP6Address *prefix;
uint32_t lt_valid, lt_pref; 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_valid = be32toh(pdprefix_option->iapdprefix.lifetime_valid);
lt_pref = be32toh(pdprefix_option->iapdprefix.lifetime_preferred); lt_pref = be32toh(pdprefix_option->iapdprefix.lifetime_preferred);
if (lt_valid == 0 || lt_pref > lt_valid) { if (lt_valid == 0 || lt_pref > lt_valid)
log_dhcp6_client(client, return log_dhcp6_client_errno(client, SYNTHETIC_ERRNO(EINVAL),
"Valid lifetieme of a PD prefix is zero or " "Valid lifetieme of a PD prefix is zero or "
"preferred lifetime %"PRIu32" > valid lifetime %"PRIu32, "preferred lifetime %"PRIu32" > valid lifetime %"PRIu32,
lt_pref, lt_valid); lt_pref, lt_valid);
return -EINVAL;
}
if (be16toh(option->len) + offsetof(DHCP6Option, data) > sizeof(*pdprefix_option)) { 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)); r = dhcp6_option_parse_status((DHCP6Option *)pdprefix_option->options, be16toh(option->len) + offsetof(DHCP6Option, data) - sizeof(*pdprefix_option));
if (r < 0) if (r < 0)
return r; return r;
if (r > 0) { if (r > 0)
log_dhcp6_client(client, "Non-zero status code '%s' for PD prefix is received", return log_dhcp6_client_errno(client, SYNTHETIC_ERRNO(EINVAL),
dhcp6_message_status_to_string(r)); "Non-zero status code '%s' for PD prefix is received",
return -EINVAL; dhcp6_message_status_to_string(r));
}
} }
prefix = new0(DHCP6Address, 1); prefix = new0(DHCP6Address, 1);
@ -515,7 +509,7 @@ static int dhcp6_option_parse_pdprefix(DHCP6Option *option, DHCP6IA *ia, uint32_
return 0; 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; uint32_t lt_t1, lt_t2, lt_valid = 0, lt_min = UINT32_MAX;
uint16_t iatype, optlen; uint16_t iatype, optlen;
size_t iaaddr_offset; 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_t1 = be32toh(ia->ia_na.lifetime_t1);
lt_t2 = be32toh(ia->ia_na.lifetime_t2); lt_t2 = be32toh(ia->ia_na.lifetime_t2);
if (lt_t1 && lt_t2 && lt_t1 > lt_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 log_dhcp6_client_errno(client, SYNTHETIC_ERRNO(EINVAL),
return -EINVAL; "IA NA T1 %"PRIu32"sec > T2 %"PRIu32"sec",
} lt_t1, lt_t2);
break; 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_t1 = be32toh(ia->ia_pd.lifetime_t1);
lt_t2 = be32toh(ia->ia_pd.lifetime_t2); lt_t2 = be32toh(ia->ia_pd.lifetime_t2);
if (lt_t1 && lt_t2 && lt_t1 > lt_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 log_dhcp6_client_errno(client, SYNTHETIC_ERRNO(EINVAL),
return -EINVAL; "IA PD T1 %"PRIu32"sec > T2 %"PRIu32"sec",
} lt_t1, lt_t2);
break; break;
@ -594,12 +588,11 @@ int dhcp6_option_parse_ia(DHCP6Option *iaoption, DHCP6IA *ia, uint16_t *ret_stat
switch (opt) { switch (opt) {
case SD_DHCP6_OPTION_IAADDR: case SD_DHCP6_OPTION_IAADDR:
if (!IN_SET(ia->type, SD_DHCP6_OPTION_IA_NA, SD_DHCP6_OPTION_IA_TA)) { 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 log_dhcp6_client_errno(client, SYNTHETIC_ERRNO(EINVAL),
return -EINVAL; "IA Address option not in IA NA or TA option");
}
r = dhcp6_option_parse_address(option, ia, &lt_valid); r = dhcp6_option_parse_address(client, option, ia, &lt_valid);
if (r < 0 && r != -EINVAL) if (r < 0 && r != -EINVAL)
return r; return r;
if (r >= 0 && lt_valid < lt_min) 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: case SD_DHCP6_OPTION_IA_PD_PREFIX:
if (!IN_SET(ia->type, SD_DHCP6_OPTION_IA_PD)) { if (!IN_SET(ia->type, SD_DHCP6_OPTION_IA_PD))
log_dhcp6_client(client, "IA PD Prefix option not in IA PD option"); return log_dhcp6_client_errno(client, SYNTHETIC_ERRNO(EINVAL),
return -EINVAL; "IA PD Prefix option not in IA PD option");
}
r = dhcp6_option_parse_pdprefix(option, ia, &lt_valid); r = dhcp6_option_parse_pdprefix(client, option, ia, &lt_valid);
if (r < 0 && r != -EINVAL) if (r < 0 && r != -EINVAL)
return r; return r;
if (r >= 0 && lt_valid < lt_min) if (r >= 0 && lt_valid < lt_min)

View File

@ -5,7 +5,7 @@
#include "sd-lldp.h" #include "sd-lldp.h"
#include "hashmap.h" #include "hashmap.h"
#include "log.h" #include "log-link.h"
#include "prioq.h" #include "prioq.h"
struct sd_lldp { struct sd_lldp {
@ -33,8 +33,18 @@ struct sd_lldp {
struct ether_addr filter_address; 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_; const char* lldp_event_to_string(sd_lldp_event_t e) _const_;
sd_lldp_event_t lldp_event_from_string(const char *s) _pure_; 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__)

View File

@ -112,7 +112,7 @@ sd_lldp_neighbor *lldp_neighbor_new(size_t raw_size) {
return n; 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; const char *p = q;
char *k; char *k;
@ -120,7 +120,7 @@ static int parse_string(char **s, const void *q, size_t n) {
assert(p || n == 0); assert(p || n == 0);
if (*s) { if (*s) {
log_lldp("Found duplicate string, ignoring field."); log_lldp(lldp, "Found duplicate string, ignoring field.");
return 0; return 0;
} }
@ -133,14 +133,14 @@ static int parse_string(char **s, const void *q, size_t n) {
/* Look for inner NULs */ /* Look for inner NULs */
if (memchr(p, 0, n)) { 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; return 0;
} }
/* Let's escape weird chars, for security reasons */ /* Let's escape weird chars, for security reasons */
k = cescape_length(p, n); k = cescape_length(p, n);
if (!k) if (!k)
return -ENOMEM; return log_oom_debug();
free(*s); free(*s);
*s = k; *s = k;
@ -156,27 +156,24 @@ int lldp_neighbor_parse(sd_lldp_neighbor *n) {
assert(n); assert(n);
if (n->raw_size < sizeof(struct ether_header)) { if (n->raw_size < sizeof(struct ether_header))
log_lldp("Received truncated packet, ignoring."); return log_lldp_errno(n->lldp, SYNTHETIC_ERRNO(EBADMSG),
return -EBADMSG; "Received truncated packet, ignoring.");
}
memcpy(&h, LLDP_NEIGHBOR_RAW(n), sizeof(h)); memcpy(&h, LLDP_NEIGHBOR_RAW(n), sizeof(h));
if (h.ether_type != htobe16(ETHERTYPE_LLDP)) { if (h.ether_type != htobe16(ETHERTYPE_LLDP))
log_lldp("Received packet with wrong type, ignoring."); return log_lldp_errno(n->lldp, SYNTHETIC_ERRNO(EBADMSG),
return -EBADMSG; "Received packet with wrong type, ignoring.");
}
if (h.ether_dhost[0] != 0x01 || if (h.ether_dhost[0] != 0x01 ||
h.ether_dhost[1] != 0x80 || h.ether_dhost[1] != 0x80 ||
h.ether_dhost[2] != 0xc2 || h.ether_dhost[2] != 0xc2 ||
h.ether_dhost[3] != 0x00 || h.ether_dhost[3] != 0x00 ||
h.ether_dhost[4] != 0x00 || h.ether_dhost[4] != 0x00 ||
!IN_SET(h.ether_dhost[5], 0x00, 0x03, 0x0e)) { !IN_SET(h.ether_dhost[5], 0x00, 0x03, 0x0e))
log_lldp("Received packet with wrong destination address, ignoring."); return log_lldp_errno(n->lldp, SYNTHETIC_ERRNO(EBADMSG),
return -EBADMSG; "Received packet with wrong destination address, ignoring.");
}
memcpy(&n->source_address, h.ether_shost, sizeof(struct ether_addr)); memcpy(&n->source_address, h.ether_shost, sizeof(struct ether_addr));
memcpy(&n->destination_address, h.ether_dhost, 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; uint8_t type;
uint16_t length; uint16_t length;
if (left < 2) { if (left < 2)
log_lldp("TLV lacks header, ignoring."); return log_lldp_errno(n->lldp, SYNTHETIC_ERRNO(EBADMSG),
return -EBADMSG; "TLV lacks header, ignoring.");
}
type = p[0] >> 1; type = p[0] >> 1;
length = p[1] + (((uint16_t) (p[0] & 1)) << 8); length = p[1] + (((uint16_t) (p[0] & 1)) << 8);
p += 2, left -= 2; p += 2, left -= 2;
if (left < length) { if (left < length)
log_lldp("TLV truncated, ignoring datagram."); return log_lldp_errno(n->lldp, SYNTHETIC_ERRNO(EBADMSG),
return -EBADMSG; "TLV truncated, ignoring datagram.");
}
switch (type) { switch (type) {
case SD_LLDP_TYPE_END: case SD_LLDP_TYPE_END:
if (length != 0) { if (length != 0)
log_lldp("End marker TLV not zero-sized, ignoring datagram."); return log_lldp_errno(n->lldp, SYNTHETIC_ERRNO(EBADMSG),
return -EBADMSG; "End marker TLV not zero-sized, ignoring datagram.");
}
/* Note that after processing the SD_LLDP_TYPE_END left could still be > 0 /* 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) */ * 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; goto end_marker;
case SD_LLDP_TYPE_CHASSIS_ID: case SD_LLDP_TYPE_CHASSIS_ID:
if (length < 2 || length > 256) { /* includes the chassis subtype, hence one extra byte */ if (length < 2 || length > 256)
log_lldp("Chassis ID field size out of range, ignoring datagram."); /* includes the chassis subtype, hence one extra byte */
return -EBADMSG; return log_lldp_errno(n->lldp, SYNTHETIC_ERRNO(EBADMSG),
} "Chassis ID field size out of range, ignoring datagram.");
if (n->id.chassis_id) {
log_lldp("Duplicate chassis ID field, ignoring datagram."); if (n->id.chassis_id)
return -EBADMSG; return log_lldp_errno(n->lldp, SYNTHETIC_ERRNO(EBADMSG),
} "Duplicate chassis ID field, ignoring datagram.");
n->id.chassis_id = memdup(p, length); n->id.chassis_id = memdup(p, length);
if (!n->id.chassis_id) if (!n->id.chassis_id)
return -ENOMEM; return log_oom_debug();
n->id.chassis_id_size = length; n->id.chassis_id_size = length;
break; break;
case SD_LLDP_TYPE_PORT_ID: case SD_LLDP_TYPE_PORT_ID:
if (length < 2 || length > 256) { /* includes the port subtype, hence one extra byte */ if (length < 2 || length > 256)
log_lldp("Port ID field size out of range, ignoring datagram."); /* includes the port subtype, hence one extra byte */
return -EBADMSG; return log_lldp_errno(n->lldp, SYNTHETIC_ERRNO(EBADMSG),
} "Port ID field size out of range, ignoring datagram.");
if (n->id.port_id) {
log_lldp("Duplicate port ID field, ignoring datagram."); if (n->id.port_id)
return -EBADMSG; return log_lldp_errno(n->lldp, SYNTHETIC_ERRNO(EBADMSG),
} "Duplicate port ID field, ignoring datagram.");
n->id.port_id = memdup(p, length); n->id.port_id = memdup(p, length);
if (!n->id.port_id) if (!n->id.port_id)
return -ENOMEM; return log_oom_debug();
n->id.port_id_size = length; n->id.port_id_size = length;
break; break;
case SD_LLDP_TYPE_TTL: case SD_LLDP_TYPE_TTL:
if (length != 2) { if (length != 2)
log_lldp("TTL field has wrong size, ignoring datagram."); return log_lldp_errno(n->lldp, SYNTHETIC_ERRNO(EBADMSG),
return -EBADMSG; "TTL field has wrong size, ignoring datagram.");
}
if (n->has_ttl) { if (n->has_ttl)
log_lldp("Duplicate TTL field, ignoring datagram."); return log_lldp_errno(n->lldp, SYNTHETIC_ERRNO(EBADMSG),
return -EBADMSG; "Duplicate TTL field, ignoring datagram.");
}
n->ttl = unaligned_read_be16(p); n->ttl = unaligned_read_be16(p);
n->has_ttl = true; n->has_ttl = true;
break; break;
case SD_LLDP_TYPE_PORT_DESCRIPTION: 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) if (r < 0)
return r; return r;
break; break;
case SD_LLDP_TYPE_SYSTEM_NAME: 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) if (r < 0)
return r; return r;
break; break;
case SD_LLDP_TYPE_SYSTEM_DESCRIPTION: 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) if (r < 0)
return r; return r;
break; break;
case SD_LLDP_TYPE_SYSTEM_CAPABILITIES: case SD_LLDP_TYPE_SYSTEM_CAPABILITIES:
if (length != 4) if (length != 4)
log_lldp("System capabilities field has wrong size, ignoring."); return log_lldp_errno(n->lldp, SYNTHETIC_ERRNO(EBADMSG),
else { "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;
}
n->system_capabilities = unaligned_read_be16(p);
n->enabled_capabilities = unaligned_read_be16(p + 2);
n->has_capabilities = true;
break; break;
case SD_LLDP_TYPE_PRIVATE: { case SD_LLDP_TYPE_PRIVATE:
if (length < 4) if (length < 4)
log_lldp("Found private TLV that is too short, ignoring."); return log_lldp_errno(n->lldp, SYNTHETIC_ERRNO(EBADMSG),
else { "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->mud_url, p + sizeof(SD_LLDP_OUI_MUD) + 1,
length - 1 - sizeof(SD_LLDP_OUI_MUD));
if (r < 0)
return r;
}
}
}
/* 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; break;
} }
@ -315,11 +304,9 @@ int lldp_neighbor_parse(sd_lldp_neighbor *n) {
} }
end_marker: end_marker:
if (!n->id.chassis_id || !n->id.port_id || !n->has_ttl) { if (!n->id.chassis_id || !n->id.port_id || !n->has_ttl)
log_lldp("One or more mandatory TLV missing in datagram. Ignoring."); return log_lldp_errno(n->lldp, SYNTHETIC_ERRNO(EBADMSG),
return -EBADMSG; "One or more mandatory TLV missing in datagram. Ignoring.");
}
n->rindex = sizeof(struct ether_header); n->rindex = sizeof(struct ether_header);

View File

@ -7,7 +7,7 @@
#include "sd-ndisc.h" #include "sd-ndisc.h"
#include "log.h" #include "log-link.h"
#include "time-util.h" #include "time-util.h"
#define NDISC_ROUTER_SOLICITATION_INTERVAL (4U * USEC_PER_SEC) #define NDISC_ROUTER_SOLICITATION_INTERVAL (4U * USEC_PER_SEC)
@ -38,8 +38,18 @@ struct sd_ndisc {
void *userdata; 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_; const char* ndisc_event_to_string(sd_ndisc_event_t e) _const_;
sd_ndisc_event_t ndisc_event_from_string(const char *s) _pure_; 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__)

View File

@ -43,7 +43,7 @@ _public_ int sd_ndisc_router_from_raw(sd_ndisc_router **ret, const void *raw, si
return -ENOMEM; return -ENOMEM;
memcpy(NDISC_ROUTER_RAW(rt), raw, raw_size); memcpy(NDISC_ROUTER_RAW(rt), raw, raw_size);
r = ndisc_router_parse(rt); r = ndisc_router_parse(NULL, rt);
if (r < 0) if (r < 0)
return r; return r;
@ -87,7 +87,7 @@ _public_ int sd_ndisc_router_get_raw(sd_ndisc_router *rt, const void **ret, size
return 0; 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; struct nd_router_advert *a;
const uint8_t *p; const uint8_t *p;
bool has_mtu = false, has_flag_extension = false; bool has_mtu = false, has_flag_extension = false;
@ -95,23 +95,20 @@ int ndisc_router_parse(sd_ndisc_router *rt) {
assert(rt); assert(rt);
if (rt->raw_size < sizeof(struct nd_router_advert)) { if (rt->raw_size < sizeof(struct nd_router_advert))
log_ndisc("Too small to be a router advertisement, ignoring."); return log_ndisc_errno(nd, SYNTHETIC_ERRNO(EBADMSG),
return -EBADMSG; "Too small to be a router advertisement, ignoring.");
}
/* Router advertisement packets are neatly aligned to 64bit boundaries, hence we can access them directly */ /* Router advertisement packets are neatly aligned to 64bit boundaries, hence we can access them directly */
a = NDISC_ROUTER_RAW(rt); a = NDISC_ROUTER_RAW(rt);
if (a->nd_ra_type != ND_ROUTER_ADVERT) { if (a->nd_ra_type != ND_ROUTER_ADVERT)
log_ndisc("Received ND packet that is not a router advertisement, ignoring."); return log_ndisc_errno(nd, SYNTHETIC_ERRNO(EBADMSG),
return -EBADMSG; "Received ND packet that is not a router advertisement, ignoring.");
}
if (a->nd_ra_code != 0) { if (a->nd_ra_code != 0)
log_ndisc("Received ND packet with wrong RA code, ignoring."); return log_ndisc_errno(nd, SYNTHETIC_ERRNO(EBADMSG),
return -EBADMSG; "Received ND packet with wrong RA code, ignoring.");
}
rt->hop_limit = a->nd_ra_curhoplimit; rt->hop_limit = a->nd_ra_curhoplimit;
rt->flags = a->nd_ra_flags_reserved; /* the first 8bit */ 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) if (left == 0)
break; break;
if (left < 2) { if (left < 2)
log_ndisc("Option lacks header, ignoring datagram."); return log_ndisc_errno(nd, SYNTHETIC_ERRNO(EBADMSG),
return -EBADMSG; "Option lacks header, ignoring datagram.");
}
type = p[0]; type = p[0];
length = p[1] * 8; length = p[1] * 8;
if (length == 0) { if (length == 0)
log_ndisc("Zero-length option, ignoring datagram."); return log_ndisc_errno(nd, SYNTHETIC_ERRNO(EBADMSG),
return -EBADMSG; "Zero-length option, ignoring datagram.");
} if (left < length)
if (left < length) { return log_ndisc_errno(nd, SYNTHETIC_ERRNO(EBADMSG),
log_ndisc("Option truncated, ignoring datagram."); "Option truncated, ignoring datagram.");
return -EBADMSG;
}
switch (type) { switch (type) {
case SD_NDISC_OPTION_PREFIX_INFORMATION: case SD_NDISC_OPTION_PREFIX_INFORMATION:
if (length != 4*8) { if (length != 4*8)
log_ndisc("Prefix option of invalid size, ignoring datagram."); return log_ndisc_errno(nd, SYNTHETIC_ERRNO(EBADMSG),
return -EBADMSG; "Prefix option of invalid size, ignoring datagram.");
}
if (p[2] > 128) { if (p[2] > 128)
log_ndisc("Bad prefix length, ignoring datagram."); return log_ndisc_errno(nd, SYNTHETIC_ERRNO(EBADMSG),
return -EBADMSG; "Bad prefix length, ignoring datagram.");
}
break; break;
@ -168,14 +160,13 @@ int ndisc_router_parse(sd_ndisc_router *rt) {
uint32_t m; uint32_t m;
if (has_mtu) { if (has_mtu) {
log_ndisc("MTU option specified twice, ignoring."); log_ndisc(nd, "MTU option specified twice, ignoring.");
break; break;
} }
if (length != 8) { if (length != 8)
log_ndisc("MTU option of invalid size, ignoring datagram."); return log_ndisc_errno(nd, SYNTHETIC_ERRNO(EBADMSG),
return -EBADMSG; "MTU option of invalid size, ignoring datagram.");
}
m = be32toh(*(uint32_t*) (p + 4)); m = be32toh(*(uint32_t*) (p + 4));
if (m >= IPV6_MIN_MTU) /* ignore invalidly small MTUs */ 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: case SD_NDISC_OPTION_ROUTE_INFORMATION:
if (length < 1*8 || length > 3*8) { if (length < 1*8 || length > 3*8)
log_ndisc("Route information option of invalid size, ignoring datagram."); return log_ndisc_errno(nd, SYNTHETIC_ERRNO(EBADMSG),
return -EBADMSG; "Route information option of invalid size, ignoring datagram.");
}
if (p[2] > 128) { if (p[2] > 128)
log_ndisc("Bad route prefix length, ignoring datagram."); return log_ndisc_errno(nd, SYNTHETIC_ERRNO(EBADMSG),
return -EBADMSG; "Bad route prefix length, ignoring datagram.");
}
break; break;
case SD_NDISC_OPTION_RDNSS: case SD_NDISC_OPTION_RDNSS:
if (length < 3*8 || (length % (2*8)) != 1*8) { if (length < 3*8 || (length % (2*8)) != 1*8)
log_ndisc("RDNSS option has invalid size."); return log_ndisc_errno(nd, SYNTHETIC_ERRNO(EBADMSG), "RDNSS option has invalid size.");
return -EBADMSG;
}
break; break;
case SD_NDISC_OPTION_FLAGS_EXTENSION: case SD_NDISC_OPTION_FLAGS_EXTENSION:
if (has_flag_extension) { if (has_flag_extension) {
log_ndisc("Flags extension option specified twice, ignoring."); log_ndisc(nd, "Flags extension option specified twice, ignoring.");
break; break;
} }
if (length < 1*8) { if (length < 1*8)
log_ndisc("Flags extension option has invalid size."); return log_ndisc_errno(nd, SYNTHETIC_ERRNO(EBADMSG),
return -EBADMSG; "Flags extension option has invalid size.");
}
/* Add in the additional flags bits */ /* Add in the additional flags bits */
rt->flags |= rt->flags |=
@ -231,10 +217,9 @@ int ndisc_router_parse(sd_ndisc_router *rt) {
break; break;
case SD_NDISC_OPTION_DNSSL: case SD_NDISC_OPTION_DNSSL:
if (length < 2*8) { if (length < 2*8)
log_ndisc("DNSSL option has invalid size."); return log_ndisc_errno(nd, SYNTHETIC_ERRNO(EBADMSG),
return -EBADMSG; "DNSSL option has invalid size.");
}
break; 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; flags = pi->nd_opt_pi_flags_reserved;
if ((flags & ND_OPT_PI_FLAG_AUTO) && (pi->nd_opt_pi_prefix_len != 64)) { 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; flags &= ~ND_OPT_PI_FLAG_AUTO;
} }

View File

@ -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); 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);

View File

@ -7,7 +7,7 @@
#include "sd-radv.h" #include "sd-radv.h"
#include "log.h" #include "log-link.h"
#include "list.h" #include "list.h"
#include "sparse-endian.h" #include "sparse-endian.h"
@ -125,6 +125,15 @@ struct sd_radv_route_prefix {
LIST_FIELDS(struct sd_radv_route_prefix, 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(radv, error, fmt, ...) \
#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__) 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__)

View File

@ -1191,7 +1191,7 @@ static int client_parse_message(
break; 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) if (r < 0 && r != -ENOMSG)
return r; return r;
@ -1224,7 +1224,7 @@ static int client_parse_message(
break; 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) if (r < 0 && r != -ENOMSG)
return r; return r;

View File

@ -206,7 +206,7 @@ int dhcp6_lease_set_dns(sd_dhcp6_lease *lease, uint8_t *optval, size_t optlen) {
lease->dns_count, lease->dns_count,
&lease->dns_allocated); &lease->dns_allocated);
if (r < 0) if (r < 0)
return log_dhcp6_client_errno(client, r, "Invalid DNS server option: %m"); return r;
lease->dns_count = 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) if (!optlen)
return 0; return 0;
if (lease->ntp || lease->ntp_fqdn) { if (lease->ntp || lease->ntp_fqdn)
log_dhcp6_client(client, "NTP information already provided"); return -EEXIST;
return 0; /* Using deprecated SNTP information */
}
log_dhcp6_client(client, "Using deprecated SNTP information");
r = dhcp6_option_parse_ip6addrs(optval, optlen, &lease->ntp, r = dhcp6_option_parse_ip6addrs(optval, optlen, &lease->ntp,
lease->ntp_count, lease->ntp_count,
&lease->ntp_allocated); &lease->ntp_allocated);
if (r < 0) if (r < 0)
return log_dhcp6_client_errno(client, r, "Invalid SNTP server option: %m"); return r;
lease->ntp_count = r; lease->ntp_count = r;

View File

@ -76,7 +76,15 @@ struct sd_ipv4acd {
}; };
#define log_ipv4acd_errno(acd, error, fmt, ...) \ #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, ...) \ #define log_ipv4acd(acd, fmt, ...) \
log_ipv4acd_errno(acd, 0, fmt, ##__VA_ARGS__) log_ipv4acd_errno(acd, 0, fmt, ##__VA_ARGS__)

View File

@ -50,7 +50,15 @@ struct sd_ipv4ll {
}; };
#define log_ipv4ll_errno(ll, error, fmt, ...) \ #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, ...) \ #define log_ipv4ll(ll, fmt, ...) \
log_ipv4ll_errno(ll, 0, fmt, ##__VA_ARGS__) log_ipv4ll_errno(ll, 0, fmt, ##__VA_ARGS__)

View File

@ -40,12 +40,10 @@ static void lldp_callback(sd_lldp *lldp, sd_lldp_event_t event, sd_lldp_neighbor
assert(lldp); assert(lldp);
assert(event >= 0 && event < _SD_LLDP_EVENT_MAX); assert(event >= 0 && event < _SD_LLDP_EVENT_MAX);
if (!lldp->callback) { if (!lldp->callback)
log_lldp("Received '%s' event.", lldp_event_to_string(event)); return (void) log_lldp(lldp, "Received '%s' event.", lldp_event_to_string(event));
return;
}
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); 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); r = lldp_add_neighbor(lldp, n);
if (r < 0) { if (r < 0) {
log_lldp_errno(r, "Failed to add datagram. Ignoring."); log_lldp_errno(lldp, r, "Failed to add datagram. Ignoring.");
return 0; return 0;
} }
log_lldp("Successfully processed LLDP datagram."); log_lldp(lldp, "Successfully processed LLDP datagram.");
return 0; return 0;
} }
@ -205,8 +203,10 @@ static int lldp_receive_datagram(sd_event_source *s, int fd, uint32_t revents, v
assert(lldp); assert(lldp);
space = next_datagram_size_fd(fd); space = next_datagram_size_fd(fd);
if (space < 0) if (space < 0) {
return log_lldp_errno(space, "Failed to determine datagram size to read: %m"); log_lldp_errno(lldp, space, "Failed to determine datagram size to read, ignoring: %m");
return 0;
}
n = lldp_neighbor_new(space); n = lldp_neighbor_new(space);
if (!n) 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)) if (IN_SET(errno, EAGAIN, EINTR))
return 0; 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) { if ((size_t) length != n->raw_size) {
log_lldp("Packet size mismatch."); log_lldp(lldp, "Packet size mismatch, ignoring");
return -EINVAL; return 0;
} }
/* Try to get the timestamp of this packet if it is known */ /* 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"); (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; return 1;
fail: fail:
@ -283,7 +284,7 @@ _public_ int sd_lldp_stop(sd_lldp *lldp) {
if (lldp->fd < 0) if (lldp->fd < 0)
return 0; return 0;
log_lldp("Stopping LLDP client"); log_lldp(lldp, "Stopping LLDP client");
lldp_reset(lldp); lldp_reset(lldp);
lldp_flush_neighbors(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; int r;
r = lldp_make_space(lldp, 0); r = lldp_make_space(lldp, 0);
if (r < 0) if (r < 0) {
return log_lldp_errno(r, "Failed to make space: %m"); log_lldp_errno(lldp, r, "Failed to make space, ignoring: %m");
return 0;
}
r = lldp_start_timer(lldp, NULL); r = lldp_start_timer(lldp, NULL);
if (r < 0) if (r < 0) {
return log_lldp_errno(r, "Failed to restart timer: %m"); log_lldp_errno(lldp, r, "Failed to restart timer, ignoring: %m");
return 0;
}
return 0; return 0;
} }

View File

@ -35,12 +35,10 @@ static void ndisc_callback(sd_ndisc *ndisc, sd_ndisc_event_t event, sd_ndisc_rou
assert(ndisc); assert(ndisc);
assert(event >= 0 && event < _SD_NDISC_EVENT_MAX); assert(event >= 0 && event < _SD_NDISC_EVENT_MAX);
if (!ndisc->callback) { if (!ndisc->callback)
log_ndisc("Received '%s' event.", ndisc_event_to_string(event)); return (void) log_ndisc(ndisc, "Received '%s' event.", ndisc_event_to_string(event));
return;
}
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); 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(nd);
assert(rt); assert(rt);
r = ndisc_router_parse(rt); r = ndisc_router_parse(nd, rt);
if (r == -EBADMSG) /* Bad packet */ if (r == -EBADMSG) /* Bad packet */
return 0; return 0;
if (r < 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) if (rt->hop_limit > 0)
nd->hop_limit = rt->hop_limit; 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->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->preference == SD_NDISC_PREFERENCE_HIGH ? "high" : rt->preference == SD_NDISC_PREFERENCE_LOW ? "low" : "medium",
rt->lifetime); rt->lifetime);
@ -233,8 +231,10 @@ static int ndisc_recv(sd_event_source *s, int fd, uint32_t revents, void *userda
assert(nd->event); assert(nd->event);
buflen = next_datagram_size_fd(fd); buflen = next_datagram_size_fd(fd);
if (buflen < 0) if (buflen < 0) {
return log_ndisc_errno(buflen, "Failed to determine datagram size to read: %m"); log_ndisc_errno(nd, buflen, "Failed to determine datagram size to read, ignoring: %m");
return 0;
}
rt = ndisc_router_new(buflen); rt = ndisc_router_new(buflen);
if (!rt) if (!rt)
@ -245,22 +245,22 @@ static int ndisc_recv(sd_event_source *s, int fd, uint32_t revents, void *userda
switch (r) { switch (r) {
case -EADDRNOTAVAIL: case -EADDRNOTAVAIL:
(void) in_addr_to_string(AF_INET6, (const union in_addr_union*) &rt->address, &addr); (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; break;
case -EMULTIHOP: case -EMULTIHOP:
log_ndisc("Received RA with invalid hop limit. Ignoring."); log_ndisc(nd, "Received RA with invalid hop limit. Ignoring.");
break; break;
case -EPFNOSUPPORT: case -EPFNOSUPPORT:
log_ndisc("Received invalid source address from ICMPv6 socket. Ignoring."); log_ndisc(nd, "Received invalid source address from ICMPv6 socket. Ignoring.");
break; break;
case -EAGAIN: /* ignore spurious wakeups */ case -EAGAIN: /* ignore spurious wakeups */
break; break;
default: 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; 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); r = icmp6_send_router_solicitation(nd->fd, &nd->mac_addr);
if (r < 0) { if (r < 0) {
log_ndisc_errno(r, "Error sending Router Solicitation: %m"); log_ndisc_errno(nd, r, "Error sending Router Solicitation: %m");
goto fail; 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, format_timespan(time_string, FORMAT_TIMESPAN_MAX,
nd->retransmit_time, USEC_PER_SEC)); 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(s);
assert(nd); 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); (void) event_source_disable(nd->timeout_no_ra);
ndisc_callback(nd, SD_NDISC_EVENT_TIMEOUT, NULL); ndisc_callback(nd, SD_NDISC_EVENT_TIMEOUT, NULL);
@ -345,7 +345,7 @@ _public_ int sd_ndisc_stop(sd_ndisc *nd) {
if (nd->fd < 0) if (nd->fd < 0)
return 0; return 0;
log_ndisc("Stopping IPv6 Router Solicitation client"); log_ndisc(nd, "Stopping IPv6 Router Solicitation client");
ndisc_reset(nd); ndisc_reset(nd);
return 1; return 1;
@ -398,7 +398,7 @@ _public_ int sd_ndisc_start(sd_ndisc *nd) {
if (r < 0) if (r < 0)
goto fail; goto fail;
log_ndisc("Started IPv6 Router Solicitation client"); log_ndisc(nd, "Started IPv6 Router Solicitation client");
return 1; return 1;
fail: fail:

View File

@ -247,22 +247,22 @@ static int radv_recv(sd_event_source *s, int fd, uint32_t revents, void *userdat
switch (r) { switch (r) {
case -EADDRNOTAVAIL: case -EADDRNOTAVAIL:
(void) in_addr_to_string(AF_INET6, (const union in_addr_union*) &src, &addr); (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; break;
case -EMULTIHOP: case -EMULTIHOP:
log_radv("Received RS with invalid hop limit. Ignoring."); log_radv(ra, "Received RS with invalid hop limit. Ignoring.");
break; break;
case -EPFNOSUPPORT: case -EPFNOSUPPORT:
log_radv("Received invalid source address from ICMPv6 socket. Ignoring."); log_radv(ra, "Received invalid source address from ICMPv6 socket. Ignoring.");
break; break;
case -EAGAIN: /* ignore spurious wakeups */ case -EAGAIN: /* ignore spurious wakeups */
break; break;
default: 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; 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)) { 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; 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); r = radv_send(ra, &src, ra->lifetime);
if (r < 0) 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 else
log_radv("Sent solicited Router Advertisement to %s", strnull(addr)); log_radv(ra, "Sent solicited Router Advertisement to %s", strnull(addr));
return 0; 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); r = radv_send(ra, NULL, ra->lifetime);
if (r < 0) 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 */ /* RFC 4861, Section 6.2.4, sending initial Router Advertisements */
if (ra->ra_sent < SD_RADV_MAX_INITIAL_RTR_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); 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, format_timespan(time_string, FORMAT_TIMESPAN_MAX,
timeout, USEC_PER_SEC)); timeout, USEC_PER_SEC));
@ -361,13 +361,13 @@ _public_ int sd_radv_stop(sd_radv *ra) {
if (ra->state == SD_RADV_STATE_IDLE) if (ra->state == SD_RADV_STATE_IDLE)
return 0; 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 /* RFC 4861, Section 6.2.5, send at least one Router Advertisement
with zero lifetime */ with zero lifetime */
r = radv_send(ra, NULL, 0); r = radv_send(ra, NULL, 0);
if (r < 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); radv_reset(ra);
ra->fd = safe_close(ra->fd); ra->fd = safe_close(ra->fd);
@ -412,7 +412,7 @@ _public_ int sd_radv_start(sd_radv *ra) {
ra->state = SD_RADV_STATE_ADVERTISING; ra->state = SD_RADV_STATE_ADVERTISING;
log_radv("Started IPv6 Router Advertisement daemon"); log_radv(ra, "Started IPv6 Router Advertisement daemon");
return 0; 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, (void) in_addr_prefix_to_string(AF_INET6,
(const union in_addr_union*) &cur->opt.in6_addr, (const union in_addr_union*) &cur->opt.in6_addr,
cur->opt.prefixlen, &addr_cur); cur->opt.prefixlen, &addr_cur);
log_radv("IPv6 prefix %s already configured, ignoring %s", return log_radv_errno(ra, SYNTHETIC_ERRNO(EEXIST),
strna(addr_cur), strna(addr_p)); "IPv6 prefix %s already configured, ignoring %s",
strna(addr_cur), strna(addr_p));
return -EEXIST;
} }
p = sd_radv_prefix_ref(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++; ra->n_prefixes++;
if (!dynamic) { if (!dynamic) {
log_radv("Added prefix %s", strna(addr_p)); log_radv(ra, "Added prefix %s", strna(addr_p));
return 0; 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) { if (ra->ra_sent > 0) {
r = radv_send(ra, NULL, ra->lifetime); r = radv_send(ra, NULL, ra->lifetime);
if (r < 0) 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 else
log_radv("Sent Router Advertisement for added prefix"); log_radv(ra, "Sent Router Advertisement for added prefix");
} }
update: 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->valid_until = valid_until;
cur->preferred_until = preferred_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), strna(addr_p),
format_timespan(time_string_preferred, FORMAT_TIMESPAN_MAX, format_timespan(time_string_preferred, FORMAT_TIMESPAN_MAX,
preferred, USEC_PER_SEC), 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, (void) in_addr_prefix_to_string(AF_INET6,
(const union in_addr_union*) &cur->opt.in6_addr, (const union in_addr_union*) &cur->opt.in6_addr,
cur->opt.prefixlen, &addr); cur->opt.prefixlen, &addr);
log_radv("IPv6 route prefix %s already configured, ignoring %s", return log_radv_errno(ra, SYNTHETIC_ERRNO(EEXIST),
strna(addr), strna(pretty)); "IPv6 route prefix %s already configured, ignoring %s",
strna(addr), strna(pretty));
return -EEXIST;
} }
p = sd_radv_route_prefix_ref(p); 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++; ra->n_route_prefixes++;
if (!dynamic) { if (!dynamic) {
log_radv("Added prefix %s", strna(pretty)); log_radv(ra, "Added prefix %s", strna(pretty));
return 0; 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) { if (ra->ra_sent > 0) {
r = radv_send(ra, NULL, ra->lifetime); r = radv_send(ra, NULL, ra->lifetime);
if (r < 0) 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 else
log_radv("Sent Router Advertisement for added route prefix"); log_radv(ra, "Sent Router Advertisement for added route prefix");
} }
update: 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) if (valid_until == USEC_INFINITY)
return -EOVERFLOW; return -EOVERFLOW;
log_radv("Updated route prefix %s valid %s", log_radv(ra, "Updated route prefix %s valid %s",
strna(pretty), strna(pretty),
format_timespan(time_string_valid, FORMAT_TIMESPAN_MAX, valid, USEC_PER_SEC)); 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) if (prefixlen > 64)
/* unusual but allowed, log it */ /* 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.in6_addr = *in6_addr;
p->opt.prefixlen = prefixlen; 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) if (prefixlen > 64)
/* unusual but allowed, log it */ /* 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.in6_addr = *in6_addr;
p->opt.prefixlen = prefixlen; p->opt.prefixlen = prefixlen;

View File

@ -295,17 +295,17 @@ static int test_option_status(sd_event *e) {
option = (DHCP6Option *)option1; option = (DHCP6Option *)option1;
assert_se(sizeof(option1) == sizeof(DHCP6Option) + be16toh(option->len)); 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(r == 0);
assert_se(ia.addresses == NULL); assert_se(ia.addresses == NULL);
option->len = htobe16(17); 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(r == -ENOBUFS);
assert_se(ia.addresses == NULL); assert_se(ia.addresses == NULL);
option->len = htobe16(sizeof(DHCP6Option)); 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(r == -ENOBUFS);
assert_se(ia.addresses == NULL); assert_se(ia.addresses == NULL);
@ -313,7 +313,7 @@ static int test_option_status(sd_event *e) {
option = (DHCP6Option *)option2; option = (DHCP6Option *)option2;
assert_se(sizeof(option2) == sizeof(DHCP6Option) + be16toh(option->len)); 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(r >= 0);
assert_se(ia.addresses == NULL); assert_se(ia.addresses == NULL);
@ -321,7 +321,7 @@ static int test_option_status(sd_event *e) {
option = (DHCP6Option *)option3; option = (DHCP6Option *)option3;
assert_se(sizeof(option3) == sizeof(DHCP6Option) + be16toh(option->len)); 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(r >= 0);
assert_se(ia.addresses != NULL); assert_se(ia.addresses != NULL);
dhcp6_lease_free_ia(&ia); dhcp6_lease_free_ia(&ia);
@ -330,7 +330,7 @@ static int test_option_status(sd_event *e) {
option = (DHCP6Option *)option4; option = (DHCP6Option *)option4;
assert_se(sizeof(option4) == sizeof(DHCP6Option) + be16toh(option->len)); 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(r >= 0);
assert_se(pd.addresses != NULL); assert_se(pd.addresses != NULL);
assert_se(memcmp(&pd.ia_pd.id, &option4[4], 4) == 0); 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; option = (DHCP6Option *)option5;
assert_se(sizeof(option5) == sizeof(DHCP6Option) + be16toh(option->len)); 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(r >= 0);
assert_se(pd.addresses != NULL); assert_se(pd.addresses != NULL);
dhcp6_lease_free_ia(&pd); dhcp6_lease_free_ia(&pd);
@ -460,7 +460,7 @@ static int test_advertise_option(sd_event *e) {
val = htobe32(120); val = htobe32(120);
assert_se(!memcmp(optval + 8, &val, sizeof(val))); 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; break;
@ -656,7 +656,7 @@ static int test_client_verify_request(DHCP6Message *request, size_t len) {
assert_se(!memcmp(optval + 8, &val, sizeof(val))); assert_se(!memcmp(optval + 8, &val, sizeof(val)));
/* Then, this should refuse all addresses. */ /* 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; break;