Not working.
port->p_id_len = strlen(set->local_id);
port->p_id_subtype = LLDP_PORTID_SUBTYPE_LOCAL;
port->p_descr_force = 0;
+ port->p_id_force = 1;
}
if (set->local_descr) {
log_debug("rpc", "requested change to Port Description");
}
/**
- * Partially serialize a port to get its configuration.
+ * Partially serialize a port to compare it
*/
static ssize_t
-lldpd_port_serialize_configuration(struct lldpd_port *port, int flags, u_int8_t **output)
+lldpd_port_serialize_partial(struct lldpd_port *port, size_t offset, u_int8_t **output)
{
ssize_t output_len;
- char save[LLDPD_PORT_START_MARKER];
+ char save[offset];
*output = NULL;
memcpy(save, port, sizeof(save));
/* coverity[suspicious_sizeof]
We intentionally partially memset port */
memset(port, 0, sizeof(save));
- port->_p_hardware_flags = flags;
output_len = lldpd_port_serialize(port, (void**)output);
memcpy(port, save, sizeof(save));
return output_len;
ssize_t len1, len2;
u_int8_t *out1, *out2;
int ret = 0;
- len1 = lldpd_port_serialize_configuration(dflt, 0, &out1);
- len2 = lldpd_port_serialize_configuration(port, 0, &out2);
+ len1 = lldpd_port_serialize_partial(dflt, LLDPD_PORT_CONFIGURATION_MARKER, &out1);
+ len2 = lldpd_port_serialize_partial(port, LLDPD_PORT_CONFIGURATION_MARKER, &out2);
+ log_debug("localchassis", "len1 = %zd, len2 = %zd", len1, len2);
if (len1 == -1 || len2 == -1) goto end;
- if (len1 == len2 && !memcmp(out1, out2, len1)) goto end;
+ if (len1 == len2) {
+ if (!memcmp(out1, out2, len1)) goto end;
+ for (int i = 0; i < len1; i++) {
+ log_debug("localchassis", "%c %4d %02X %02X",
+ (out1[i] == out2[i])?' ':'*',
+ i, out1[i], out2[i]);
+ }
+ }
ret = 1;
end:
free(out1);
* change. To do this, we zero out fields that are not
* significant, marshal the port, then restore. */
struct lldpd_port *port = &hardware->h_lport;
+ port->_p_hardware_flags = hardware->h_flags;
u_int8_t *output = NULL;
- ssize_t output_len = lldpd_port_serialize_configuration(
- port, hardware->h_flags, &output);
+ ssize_t output_len = lldpd_port_serialize_partial(
+ port, LLDPD_PORT_START_MARKER, &output);
if (output_len == -1) {
log_warnx("localchassis",
"unable to serialize local port %s to check for differences",
u_int8_t p_protocol; /* Protocol used to get this port */
u_int8_t p_hidden_in:1; /* Considered as hidden for reception */
u_int8_t p_hidden_out:2; /* Considered as hidden for emission */
- u_int8_t p_disable_rx:3; /* Should RX be disabled for this port? */
- u_int8_t p_disable_tx:4; /* Should TX be disabled for this port? */
/* Important: all fields that should be ignored to check if a port has
* been changed should be before this mark. */
#define LLDPD_PORT_START_MARKER (offsetof(struct lldpd_port, _p_hardware_flags))
char *p_id;
int p_id_len;
char *p_descr;
- int p_descr_force; /* Description has been forced by user */
u_int16_t p_mfs;
u_int16_t p_ttl; /* TTL for remote port */
#ifdef ENABLE_DOT3
- /* Dot3 stuff */
u_int32_t p_aggregid;
struct lldpd_dot3_macphy p_macphy;
- struct lldpd_dot3_power p_power;
#endif
-
#ifdef ENABLE_LLDPMED
u_int16_t p_med_cap_enabled;
- struct lldpd_med_policy p_med_policy[LLDP_MED_APPTYPE_LAST];
- struct lldpd_med_loc p_med_location[LLDP_MED_LOCFORMAT_LAST];
- struct lldpd_med_power p_med_power;
#endif
-
#ifdef ENABLE_DOT1
u_int16_t p_pvid;
TAILQ_HEAD(, lldpd_vlan) p_vlans;
TAILQ_HEAD(, lldpd_ppvid) p_ppvids;
TAILQ_HEAD(, lldpd_pi) p_pids;
#endif
+
+ /* Below is user-controlled */
+
+#define LLDPD_PORT_CONFIGURATION_MARKER (offsetof(struct lldpd_port, p_id_force))
+ int p_id_force; /* Port ID has been forced by user */
+ int p_descr_force; /* Description has been forced by user */
+ u_int8_t p_disable_rx:1; /* Should RX be disabled for this port? */
+ u_int8_t p_disable_tx:2; /* Should TX be disabled for this port? */
+
+#ifdef ENABLE_DOT3
+ struct lldpd_dot3_power p_power;
+#endif
+
+#ifdef ENABLE_LLDPMED
+ struct lldpd_med_policy p_med_policy[LLDP_MED_APPTYPE_LAST];
+ struct lldpd_med_loc p_med_location[LLDP_MED_LOCFORMAT_LAST];
+ struct lldpd_med_power p_med_power;
+#endif
+
#ifdef ENABLE_CUSTOM
TAILQ_HEAD(, lldpd_custom) p_custom_list;
#endif
void *source;
void *target = NULL;
if (current->kind == ignore) {
+ log_debug("marshal", "ignore from %zu (%zu)", current->offset, current->offset2);
memset((unsigned char *)serialized->object + current->offset, 0, current->offset2);
continue;
}
/* Append the result, force alignment to be able to unserialize it */
padlen = ALIGNOF(struct marshal_serialized);
padlen = (padlen - (len % padlen)) % padlen;
+ log_debug("marshal", "realloc %lu", len + padlen + sublen);
new = realloc(serialized, len + padlen + sublen);
if (!new) {
log_warnx("marshal", "unable to allocate more memory to serialize structure %s",