Skip to content

Commit 320b2bd

Browse files
KanjiMonsterthom311
authored andcommitted
bridge_info: implement missing rtnl_link_info_ops::io_compare()
Without rtnl_link_info_ops::io_compare() changes in link info are not picked up by the cache and no notificatons are sent out as rtnl_link_info_data_compare() returns 0 when the callback is missing. Fix this by implementing the missing io_compare() for bridge_info. This allows e.g. changes in ageing time to be seen. Fixes: 7391a38 ("bridge: Add support for link_info of a bridge") Signed-off-by: Jonas Gorski <[email protected]> #427
1 parent 69231b6 commit 320b2bd

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

lib/route/link/bridge_info.c

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,13 +261,61 @@ static void bridge_info_free(struct rtnl_link *link)
261261
_nl_clear_free(&link->l_info);
262262
}
263263

264+
static int bridge_info_compare(struct rtnl_link *link_a,
265+
struct rtnl_link *link_b, int flags)
266+
{
267+
struct bridge_info *a = link_a->l_info;
268+
struct bridge_info *b = link_b->l_info;
269+
uint32_t attrs = flags & LOOSE_COMPARISON ? b->ce_mask : ~0u;
270+
int diff = 0;
271+
272+
#define _DIFF(ATTR, EXPR) ATTR_DIFF(attrs, ATTR, a, b, EXPR)
273+
diff |= _DIFF(BRIDGE_ATTR_VLAN_FILTERING,
274+
a->b_vlan_filtering != b->b_vlan_filtering);
275+
diff |= _DIFF(BRIDGE_ATTR_VLAN_PROTOCOL,
276+
a->b_vlan_protocol != b->b_vlan_protocol);
277+
diff |= _DIFF(BRIDGE_ATTR_VLAN_STATS_ENABLED,
278+
a->b_vlan_stats_enabled != b->b_vlan_stats_enabled);
279+
diff |= _DIFF(BRIDGE_ATTR_AGEING_TIME,
280+
a->b_ageing_time != b->b_ageing_time);
281+
diff |= _DIFF(BRIDGE_ATTR_VLAN_DEFAULT_PVID,
282+
a->b_vlan_default_pvid != b->b_vlan_default_pvid);
283+
diff |= _DIFF(BRIDGE_ATTR_NF_CALL_IPTABLES,
284+
a->b_nf_call_iptables != b->b_nf_call_iptables);
285+
diff |= _DIFF(BRIDGE_ATTR_NF_CALL_IP6TABLES,
286+
a->b_nf_call_ip6tables != b->b_nf_call_ip6tables);
287+
diff |= _DIFF(BRIDGE_ATTR_NF_CALL_ARPTABLES,
288+
a->b_nf_call_arptables != b->b_nf_call_arptables);
289+
diff |= _DIFF(BRIDGE_ATTR_STP_STATE, a->b_stp_state != b->b_stp_state);
290+
diff |= _DIFF(BRIDGE_ATTR_MCAST_ROUTER,
291+
a->b_mcast_router != b->b_mcast_router);
292+
diff |= _DIFF(BRIDGE_ATTR_MCAST_SNOOPING,
293+
a->b_mcast_snooping != b->b_mcast_snooping);
294+
295+
if (flags & LOOSE_COMPARISON)
296+
diff |= _DIFF(
297+
BRIDGE_ATTR_BOOLOPT,
298+
(b->b_boolopts.optmask & ~a->b_boolopts.optmask) ||
299+
((a->b_boolopts.optval ^ b->b_boolopts.optval) &
300+
b->b_boolopts.optmask));
301+
else
302+
diff |= _DIFF(
303+
BRIDGE_ATTR_BOOLOPT,
304+
(a->b_boolopts.optmask != b->b_boolopts.optmask) ||
305+
(a->b_boolopts.optval != b->b_boolopts.optval));
306+
#undef _DIFF
307+
308+
return diff;
309+
}
310+
264311
static struct rtnl_link_info_ops bridge_info_ops = {
265312
.io_name = "bridge",
266313
.io_alloc = bridge_info_alloc,
267314
.io_clone = bridge_info_clone,
268315
.io_parse = bridge_info_parse,
269316
.io_put_attrs = bridge_info_put_attrs,
270317
.io_free = bridge_info_free,
318+
.io_compare = bridge_info_compare,
271319
};
272320

273321
#define IS_BRIDGE_INFO_ASSERT(link) \

0 commit comments

Comments
 (0)