1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-09 00:00:04 +01:00

netlink: route handling checks for SRC when it means DST

https://github.com/warmcat/libwebsockets/issues/2603
This commit is contained in:
wayneonway 2022-04-06 14:54:01 +08:00 committed by Andy Green
parent 3268db0ae8
commit ec81f538be
3 changed files with 4 additions and 3 deletions

View file

@ -1375,6 +1375,7 @@ _lws_routing_table_dump(struct lws_context *cx);
#define LRR_IGNORE_PRI (1 << 0)
#define LRR_MATCH_SRC (1 << 1)
#define LRR_MATCH_DST (1 << 2)
lws_route_t *
_lws_route_remove(struct lws_context_per_thread *pt, lws_route_t *robj, int flags);

View file

@ -146,7 +146,7 @@ _lws_route_remove(struct lws_context_per_thread *pt, lws_route_t *robj, int flag
lws_route_t *rou = lws_container_of(d, lws_route_t, list);
if ((!(flags & LRR_MATCH_SRC) || !lws_sa46_compare_ads(&robj->src, &rou->src)) &&
((flags & LRR_MATCH_SRC) || !lws_sa46_compare_ads(&robj->dest, &rou->dest)) &&
(!(flags & LRR_MATCH_DST) || !lws_sa46_compare_ads(&robj->dest, &rou->dest)) &&
(!robj->gateway.sa4.sin_family ||
!lws_sa46_compare_ads(&robj->gateway, &rou->gateway)) &&
robj->dest_len <= rou->dest_len &&

View file

@ -371,8 +371,8 @@ ana:
lws_pt_lock(pt, __func__);
/* returns zero on match already in table */
rmat = _lws_route_remove(pt, &robj, LRR_MATCH_SRC |
LRR_IGNORE_PRI);
rmat = _lws_route_remove(pt, &robj, h->nlmsg_type == RTM_NEWROUTE ?
LRR_MATCH_DST : LRR_MATCH_SRC | LRR_IGNORE_PRI);
lws_pt_unlock(pt);
if (rmat) {