mirror of
https://github.com/warmcat/libwebsockets.git
synced 2025-03-09 00:00:04 +01:00
route: assert if route table becomes full
This commit is contained in:
parent
12f20503b4
commit
e2f42387b7
7 changed files with 42 additions and 13 deletions
|
@ -61,7 +61,7 @@
|
|||
"default": false
|
||||
},
|
||||
"freertos-linkit/arm32-m4-mt7697-usi/gcc": {
|
||||
"build": "mkdir build;cd build;export CCACHE_DISABLE=1;cmake .. -DCMAKE_INSTALL_PREFIX:PATH=/tmp -DCMAKE_TOOLCHAIN_FILE=../contrib/cross-linkit.cmake -DLWS_PLAT_FREERTOS=1 -DLWS_WITH_ZLIB=0 -DLWS_WITHOUT_EXTENSIONS=1 -DLWS_WITH_ZIP_FOPS=0 -DLWS_WITH_HTTP_STREAM_COMPRESSION=0 -DLWS_WITH_MBEDTLS=1 -DLWS_WITH_FILE_OPS=0 ${cmake};make -j",
|
||||
"build": "mkdir build;cd build;export CCACHE_DISABLE=1;cmake .. -DCMAKE_INSTALL_PREFIX:PATH=/tmp -DCMAKE_TOOLCHAIN_FILE=../contrib/cross-linkit.cmake -DLWS_PLAT_FREERTOS=1 -DLWS_WITH_ZLIB=0 -DLWS_WITHOUT_EXTENSIONS=1 -DLWS_WITH_ZIP_FOPS=0 -DLWS_WITH_HTTP_STREAM_COMPRESSION=0 -DLWS_WITH_MBEDTLS=1 -DLWS_WITH_FILE_OPS=0 -DLWS_IPV6=0 ${cmake};make -j",
|
||||
"default": false
|
||||
},
|
||||
"w10/x86_64-amd/msvc": {
|
||||
|
@ -118,17 +118,17 @@
|
|||
"platforms": "w10/x86_64-amd/msvc, w10/x86_64-amd/noptmsvc, freertos-linkit/arm32-m4-mt7697-usi/gcc, linux-ubuntu-2004/aarch64-a72-bcm2711-rpi4/gcc, w10/x86_64-amd/mingw32, w10/x86_64-amd/mingw64, netbsd/aarch64BE-bcm2837-a53/gcc, w10/x86_64-amd/wmbedtlsmsvc"
|
||||
},
|
||||
"esp32-heltec": {
|
||||
"cmake": "",
|
||||
"cmake": "-DLWS_IPV6=0",
|
||||
"cpack": "esp-heltec-wb32",
|
||||
"platforms": "none, freertos-espidf/xl6-esp32/gcc"
|
||||
},
|
||||
"esp32-wrover": {
|
||||
"cmake": "",
|
||||
"cmake": "-DLWS_IPV6=0",
|
||||
"cpack": "esp-wrover-kit",
|
||||
"platforms": "none, freertos-espidf/xl6-esp32/gcc"
|
||||
},
|
||||
"esp32-wrover-static": {
|
||||
"cmake": "-DLWS_WITH_SECURE_STREAMS_STATIC_POLICY_ONLY=1 ",
|
||||
"cmake": "-DLWS_WITH_SECURE_STREAMS_STATIC_POLICY_ONLY=1 -DLWS_IPV6=0",
|
||||
"cpack": "esp-wrover-kit",
|
||||
"platforms": "none, freertos-espidf/xl6-esp32/gcc"
|
||||
},
|
||||
|
|
|
@ -49,7 +49,9 @@ lws_getaddrinfo46(struct lws *wsi, const char *ads, struct addrinfo **result)
|
|||
|
||||
#if !defined(__ANDROID__)
|
||||
hints.ai_family = AF_UNSPEC;
|
||||
#if !defined(__OpenBSD__) && !defined(__OPENBSD)
|
||||
hints.ai_flags = AI_V4MAPPED;
|
||||
#endif
|
||||
#endif
|
||||
} else
|
||||
#endif
|
||||
|
|
|
@ -179,10 +179,6 @@ lws_client_connect_3_connect(struct lws *wsi, const char *ads,
|
|||
result = NULL;
|
||||
}
|
||||
|
||||
#if defined(LWS_WITH_IPV6) && defined(__ANDROID__)
|
||||
ipv6only = 0;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* async dns calls back here for everybody who cares when it gets a
|
||||
* result... but if we are piggybacking, we do not want to connect
|
||||
|
|
|
@ -170,6 +170,8 @@ lws_sort_dns_classify(lws_sockaddr46 *sa46, lws_dns_score_t *score)
|
|||
lws_sockaddr46 s;
|
||||
int n, m;
|
||||
|
||||
memset(score, 0, sizeof(*score));
|
||||
|
||||
if (sa46->sa4.sin_family == AF_INET) {
|
||||
memset(&s, 0, sizeof(s));
|
||||
s.sa6.sin6_family = AF_INET6;
|
||||
|
@ -572,7 +574,7 @@ lws_sort_dns_dump(struct lws *wsi)
|
|||
lws_sa46_write_numeric_address(&s->dest, dest, sizeof(dest));
|
||||
lws_sa46_write_numeric_address(&s->gateway, gw, sizeof(gw));
|
||||
|
||||
lwsl_notice("%s: %d: (%d)%s, gw (%d)%s, idi: %d, "
|
||||
lwsl_info("%s: %d: (%d)%s, gw (%d)%s, idi: %d, "
|
||||
"lbl: %d, prec: %d\n",
|
||||
__func__, n++, s->dest.sa4.sin_family, dest,
|
||||
s->gateway.sa4.sin_family, gw,
|
||||
|
|
|
@ -1356,8 +1356,9 @@ _lws_routing_table_dump(struct lws_context *cx);
|
|||
|
||||
#define LRR_IGNORE_PRI (1 << 0)
|
||||
#define LRR_MATCH_SRC (1 << 1)
|
||||
#define LRR_JUST_CHECK (1 << 2)
|
||||
|
||||
int
|
||||
lws_route_t *
|
||||
_lws_route_remove(struct lws_context_per_thread *pt, lws_route_t *robj, int flags);
|
||||
|
||||
void
|
||||
|
|
|
@ -114,6 +114,10 @@ _lws_route_get_uidx(struct lws_context *cx)
|
|||
cx->route_uidx++;
|
||||
if (!cx->route_uidx)
|
||||
cx->route_uidx++;
|
||||
if (again) {
|
||||
assert(0); /* we have filled up the 8-bit uidx space? */
|
||||
return 0;
|
||||
}
|
||||
again = 1;
|
||||
}
|
||||
} lws_end_foreach_dll(d);
|
||||
|
@ -123,7 +127,7 @@ _lws_route_get_uidx(struct lws_context *cx)
|
|||
}
|
||||
}
|
||||
|
||||
int
|
||||
lws_route_t *
|
||||
_lws_route_remove(struct lws_context_per_thread *pt, lws_route_t *robj, int flags)
|
||||
{
|
||||
lws_start_foreach_dll_safe(struct lws_dll2 *, d, d1,
|
||||
|
@ -139,6 +143,8 @@ _lws_route_remove(struct lws_context_per_thread *pt, lws_route_t *robj, int flag
|
|||
((flags & LRR_IGNORE_PRI) ||
|
||||
robj->priority == rou->priority)
|
||||
) {
|
||||
if (flags & LRR_JUST_CHECK)
|
||||
return rou;
|
||||
lwsl_info("%s: deleting route\n", __func__);
|
||||
_lws_route_pt_close_route_users(pt, robj->uidx);
|
||||
lws_dll2_remove(&rou->list);
|
||||
|
@ -147,7 +153,7 @@ _lws_route_remove(struct lws_context_per_thread *pt, lws_route_t *robj, int flag
|
|||
|
||||
} lws_end_foreach_dll_safe(d, d1);
|
||||
|
||||
return 1;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -68,7 +68,7 @@ rops_handle_POLLIN_netlink(struct lws_context_per_thread *pt, struct lws *wsi,
|
|||
#endif
|
||||
;
|
||||
struct sockaddr_nl nladdr;
|
||||
lws_route_t robj, *rou;
|
||||
lws_route_t robj, *rou, *rmat;
|
||||
struct nlmsghdr *h;
|
||||
struct msghdr msg;
|
||||
struct iovec iov;
|
||||
|
@ -374,6 +374,27 @@ rops_handle_POLLIN_netlink(struct lws_context_per_thread *pt, struct lws *wsi,
|
|||
|
||||
lwsl_netlink("%s: NEWADDR\n", __func__);
|
||||
ana:
|
||||
|
||||
/*
|
||||
* Is robj a dupe in the routing table already?
|
||||
*
|
||||
* match on pri ignore == set pri and skip
|
||||
* no match == add
|
||||
*/
|
||||
|
||||
lws_pt_lock(pt, __func__);
|
||||
|
||||
/* returns zero on match already in table */
|
||||
rmat = _lws_route_remove(pt, &robj, LRR_MATCH_SRC |
|
||||
LRR_JUST_CHECK |
|
||||
LRR_IGNORE_PRI);
|
||||
lws_pt_unlock(pt);
|
||||
|
||||
if (rmat) {
|
||||
rmat->priority = robj.priority;
|
||||
break;
|
||||
}
|
||||
|
||||
rou = lws_malloc(sizeof(*rou), __func__);
|
||||
if (!rou) {
|
||||
lwsl_err("%s: oom\n", __func__);
|
||||
|
@ -391,6 +412,7 @@ ana:
|
|||
|
||||
rou->uidx = _lws_route_get_uidx(cx);
|
||||
lws_dll2_add_tail(&rou->list, &cx->routing_table);
|
||||
lwsl_info("%s: route list size %u\n", __func__, cx->routing_table.count);
|
||||
|
||||
_lws_route_pt_close_unroutable(pt);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue