mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-05 19:18:00 +02:00
lldp: merge branch 'th/lldp-bgo763499'
https://bugzilla.gnome.org/show_bug.cgi?id=763499
This commit is contained in:
commit
d4ca43613e
8 changed files with 567 additions and 427 deletions
|
|
@ -287,8 +287,10 @@ _NM_IN_STRSET_streq (const char *x, const char *s)
|
|||
|
||||
#if NM_MORE_ASSERTS
|
||||
#define nm_assert(cond) G_STMT_START { g_assert (cond); } G_STMT_END
|
||||
#define nm_assert_not_reached() G_STMT_START { g_assert_not_reached (); } G_STMT_END
|
||||
#else
|
||||
#define nm_assert(cond) G_STMT_START { if (FALSE) { if (cond) { } } } G_STMT_END
|
||||
#define nm_assert_not_reached() G_STMT_START { ; } G_STMT_END
|
||||
#endif
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
@ -313,6 +315,18 @@ _notify (obj_type *obj, _PropertyEnums prop) \
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
#define nm_unauto(pp) \
|
||||
({ \
|
||||
G_STATIC_ASSERT (sizeof *(pp) == sizeof (gpointer)); \
|
||||
gpointer *_pp = (gpointer *) (pp); \
|
||||
gpointer _p = *_pp; \
|
||||
\
|
||||
*_pp = NULL; \
|
||||
_p; \
|
||||
})
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static inline gpointer
|
||||
nm_g_object_ref (gpointer obj)
|
||||
{
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -335,7 +335,7 @@ _test_recv_data2_ttl1_check (GMainLoop *loop, NMLldpListener *listener)
|
|||
/* wait for signal. */
|
||||
notify_id = g_signal_connect (listener, "notify::" NM_LLDP_LISTENER_NEIGHBORS,
|
||||
nmtst_main_loop_quit_on_notify, loop);
|
||||
if (!nmtst_main_loop_run (loop, 20000))
|
||||
if (!nmtst_main_loop_run (loop, 5000))
|
||||
g_assert_not_reached ();
|
||||
nm_clear_g_signal_handler (listener, ¬ify_id);
|
||||
|
||||
|
|
|
|||
|
|
@ -317,6 +317,9 @@ int nm_utils_cmp_connection_by_autoconnect_priority (NMConnection **a, NMConnect
|
|||
void nm_utils_log_connection_diff (NMConnection *connection, NMConnection *diff_base, guint32 level, guint64 domain, const char *name, const char *prefix);
|
||||
|
||||
#define NM_UTILS_NS_PER_SECOND ((gint64) 1000000000)
|
||||
#define NM_UTILS_NS_PER_MSEC ((gint64) 1000000)
|
||||
#define NM_UTILS_NS_TO_MSEC_CEIL(nsec) (((nsec) + (NM_UTILS_NS_PER_MSEC - 1)) / NM_UTILS_NS_PER_MSEC)
|
||||
|
||||
gint64 nm_utils_get_monotonic_timestamp_ns (void);
|
||||
gint64 nm_utils_get_monotonic_timestamp_us (void);
|
||||
gint64 nm_utils_get_monotonic_timestamp_ms (void);
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ static struct {
|
|||
char *logging_domains_to_string;
|
||||
const LogLevelDesc level_desc[_LOGL_N];
|
||||
|
||||
#define _DOMAIN_DESC_LEN 36
|
||||
#define _DOMAIN_DESC_LEN 37
|
||||
/* Would be nice to use C99 flexible array member here,
|
||||
* but that feature doesn't seem well supported. */
|
||||
const LogDesc domain_desc[_DOMAIN_DESC_LEN];
|
||||
|
|
@ -164,6 +164,7 @@ static struct {
|
|||
{ LOGD_DCB, "DCB" },
|
||||
{ LOGD_DISPATCH, "DISPATCH" },
|
||||
{ LOGD_AUDIT, "AUDIT" },
|
||||
{ LOGD_SYSTEMD, "SYSTEMD" },
|
||||
{ 0, NULL }
|
||||
/* keep _DOMAIN_DESC_LEN in sync */
|
||||
},
|
||||
|
|
|
|||
|
|
@ -64,6 +64,7 @@ typedef enum { /*< skip >*/
|
|||
LOGD_DCB = (1LL << 32), /* Data Center Bridging */
|
||||
LOGD_DISPATCH = (1LL << 33),
|
||||
LOGD_AUDIT = (1LL << 34),
|
||||
LOGD_SYSTEMD = (1LL << 35),
|
||||
|
||||
__LOGD_MAX,
|
||||
LOGD_ALL = ((__LOGD_MAX - 1LL) << 1) - 1LL,
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ _slog_level_to_nm (int slevel)
|
|||
const int _nm_e = (error); \
|
||||
const NMLogLevel _nm_l = _slog_level_to_nm ((level)); \
|
||||
\
|
||||
if (nm_logging_enabled (_nm_l, LOGD_DHCP)) { \
|
||||
if (nm_logging_enabled (_nm_l, LOGD_SYSTEMD)) { \
|
||||
const char *_nm_location = strrchr ((""file), '/'); \
|
||||
\
|
||||
_nm_log_impl (_nm_location ? _nm_location + 1 : (""file), (line), (func), _nm_l, LOGD_DHCP, _nm_e, ("%s"format), "libsystemd: ", ## __VA_ARGS__); \
|
||||
|
|
|
|||
|
|
@ -114,6 +114,8 @@ static bool lldp_keep_neighbor(sd_lldp *lldp, sd_lldp_neighbor *n) {
|
|||
return true;
|
||||
}
|
||||
|
||||
static int lldp_start_timer(sd_lldp *lldp, sd_lldp_neighbor *neighbor);
|
||||
|
||||
static int lldp_add_neighbor(sd_lldp *lldp, sd_lldp_neighbor *n) {
|
||||
_cleanup_(sd_lldp_neighbor_unrefp) sd_lldp_neighbor *old = NULL;
|
||||
bool keep;
|
||||
|
|
@ -138,7 +140,7 @@ static int lldp_add_neighbor(sd_lldp *lldp, sd_lldp_neighbor *n) {
|
|||
|
||||
if (lldp_neighbor_equal(n, old)) {
|
||||
/* Is this equal, then restart the TTL counter, but don't do anyting else. */
|
||||
lldp_neighbor_start_ttl(old);
|
||||
lldp_start_timer(lldp, old);
|
||||
lldp_callback(lldp, SD_LLDP_EVENT_REFRESHED, old);
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -164,7 +166,7 @@ static int lldp_add_neighbor(sd_lldp *lldp, sd_lldp_neighbor *n) {
|
|||
|
||||
n->lldp = lldp;
|
||||
|
||||
lldp_neighbor_start_ttl(n);
|
||||
lldp_start_timer(lldp, n);
|
||||
lldp_callback(lldp, old ? SD_LLDP_EVENT_UPDATED : SD_LLDP_EVENT_ADDED, n);
|
||||
|
||||
return 1;
|
||||
|
|
@ -370,8 +372,6 @@ static int neighbor_compare_func(const void *a, const void *b) {
|
|||
return lldp_neighbor_id_hash_ops.compare(&(*x)->id, &(*y)->id);
|
||||
}
|
||||
|
||||
static int lldp_start_timer(sd_lldp *lldp);
|
||||
|
||||
static int on_timer_event(sd_event_source *s, uint64_t usec, void *userdata) {
|
||||
sd_lldp *lldp = userdata;
|
||||
int r, q;
|
||||
|
|
@ -380,19 +380,22 @@ static int on_timer_event(sd_event_source *s, uint64_t usec, void *userdata) {
|
|||
if (r < 0)
|
||||
return log_lldp_errno(r, "Failed to make space: %m");
|
||||
|
||||
q = lldp_start_timer(lldp);
|
||||
q = lldp_start_timer(lldp, NULL);
|
||||
if (q < 0)
|
||||
return log_lldp_errno(q, "Failed to restart timer: %m");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int lldp_start_timer(sd_lldp *lldp) {
|
||||
static int lldp_start_timer(sd_lldp *lldp, sd_lldp_neighbor *neighbor) {
|
||||
sd_lldp_neighbor *n;
|
||||
int r;
|
||||
|
||||
assert(lldp);
|
||||
|
||||
if (neighbor)
|
||||
lldp_neighbor_start_ttl(neighbor);
|
||||
|
||||
n = prioq_peek(lldp->neighbor_by_expiry);
|
||||
if (!n) {
|
||||
|
||||
|
|
@ -442,7 +445,7 @@ _public_ int sd_lldp_get_neighbors(sd_lldp *lldp, sd_lldp_neighbor ***ret) {
|
|||
if (!l)
|
||||
return -ENOMEM;
|
||||
|
||||
r = lldp_start_timer(lldp);
|
||||
r = lldp_start_timer(lldp, NULL);
|
||||
if (r < 0) {
|
||||
free(l);
|
||||
return r;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue