mirror of
https://github.com/warmcat/libwebsockets.git
synced 2025-03-09 00:00:04 +01:00
route: fix nl groups and local ipv6 ads
This commit is contained in:
parent
442f9aeaa8
commit
84956d280a
2 changed files with 19 additions and 8 deletions
|
@ -38,25 +38,30 @@ void
|
|||
_lws_routing_entry_dump(struct lws_context *cx, lws_route_t *rou)
|
||||
{
|
||||
char sa[48], fin[192], *end = &fin[sizeof(fin)];
|
||||
char *it = fin;
|
||||
int n;
|
||||
|
||||
fin[0] = '\0';
|
||||
|
||||
if (rou->dest.sa4.sin_family) {
|
||||
lws_sa46_write_numeric_address(&rou->dest, sa, sizeof(sa));
|
||||
lws_snprintf(fin, lws_ptr_diff_size_t(end, fin),
|
||||
n = lws_snprintf(it, lws_ptr_diff_size_t(end, it),
|
||||
"dst: %s/%d, ", sa, rou->dest_len);
|
||||
it = it + n;
|
||||
}
|
||||
|
||||
if (rou->src.sa4.sin_family) {
|
||||
lws_sa46_write_numeric_address(&rou->src, sa, sizeof(sa));
|
||||
lws_snprintf(fin, lws_ptr_diff_size_t(end, fin),
|
||||
n = lws_snprintf(it, lws_ptr_diff_size_t(end, it),
|
||||
"src: %s/%d, ", sa, rou->src_len);
|
||||
it = it + n;
|
||||
}
|
||||
|
||||
if (rou->gateway.sa4.sin_family) {
|
||||
lws_sa46_write_numeric_address(&rou->gateway, sa, sizeof(sa));
|
||||
lws_snprintf(fin, lws_ptr_diff_size_t(end, fin),
|
||||
n = lws_snprintf(it, lws_ptr_diff_size_t(end, it),
|
||||
"gw: %s, ", sa);
|
||||
it = it + n;
|
||||
}
|
||||
|
||||
lwsl_cx_info(cx, " %s ifidx: %d, pri: %d, proto: %d\n", fin,
|
||||
|
|
|
@ -259,6 +259,15 @@ rops_handle_POLLIN_netlink(struct lws_context_per_thread *pt, struct lws *wsi,
|
|||
lwsl_cx_netlink(cx, "RTA_SRC: %s", buf);
|
||||
break;
|
||||
case RTA_DST:
|
||||
/* check if is local addr -> considering it as src addr too */
|
||||
if (rm->rtm_type == RTN_LOCAL &&
|
||||
((rm->rtm_family == AF_INET && rm->rtm_dst_len == 32) ||
|
||||
(rm->rtm_family == AF_INET6 && rm->rtm_dst_len == 128))) {
|
||||
lws_sa46_copy_address(&robj.src, RTA_DATA(ra),
|
||||
rm->rtm_family);
|
||||
lwsl_cx_netlink(cx, "Local addr: RTA_DST -> added to RTA_SRC");
|
||||
}
|
||||
|
||||
lws_sa46_copy_address(&robj.dest, RTA_DATA(ra),
|
||||
rm->rtm_family);
|
||||
robj.dest_len = rm->rtm_dst_len;
|
||||
|
@ -519,12 +528,9 @@ rops_pt_init_destroy_netlink(struct lws_context *context,
|
|||
memset(&sanl, 0, sizeof(sanl));
|
||||
sanl.nl_family = AF_NETLINK;
|
||||
sanl.nl_pid = (uint32_t)getpid();
|
||||
sanl.nl_groups = (1 << (RTNLGRP_LINK - 1)) |
|
||||
(1 << (RTNLGRP_IPV4_ROUTE - 1)) |
|
||||
(1 << (RTNLGRP_IPV4_IFADDR - 1))
|
||||
sanl.nl_groups = RTMGRP_LINK | RTMGRP_IPV4_ROUTE | RTMGRP_IPV4_IFADDR
|
||||
#if defined(LWS_WITH_IPV6)
|
||||
| (1 << (RTNLGRP_IPV6_ROUTE - 1)) |
|
||||
(1 << (RTNLGRP_IPV6_IFADDR - 1))
|
||||
| RTMGRP_IPV6_ROUTE | RTMGRP_IPV6_IFADDR
|
||||
#endif
|
||||
;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue