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

25 commits

Author SHA1 Message Date
Andy Green
2a5c8913a8 centos7: remove obsolete workaround
Need for this seems to have gone away

https://github.com/warmcat/libwebsockets/issues/2729
2024-09-23 11:01:17 +01:00
p-luke
e4be3317ee netlink: when binding the per-context socket, let the kernel choose the unicast address.
When using multiple client contextes in a single application, rops_pt_init_destroy_netlink() fails binding the second socket and on - only the first one succeeds. The failure is made obvious by this log:
  W: rops_pt_init_destroy_netlink: netlink bind failed

So, let's fix this by doing what netlink(7) man page suggests:
  If the application sets nl_pid before calling bind(2), then it is up to the
  application to make sure that nl_pid is unique. If the application sets it
  to 0, the kernel takes care of assigning it. The kernel assigns the process
  ID to the first netlink socket the process opens and assigns a unique nl_pid
  to every netlink socket that the process subsequently creates.
2024-03-20 07:29:11 +00:00
Mark Butowski
7ef2065fdf netlink: fix errant route delete on NEWADDR
NEWADDR was errantly deleting route entities, specifically it happend
to delete IPv6 route entries causing a disconnect of all IPv6 clients.
NEWADDR can be issued on a DHCP lease renew, which does not change any
of the routes.

Code was also cleaned up a bit, and added some helpful logging.
2023-09-24 08:27:04 +01:00
wayneonway
61880e15ff netlink: route handling checks for SRC when it means DST
https://github.com/warmcat/libwebsockets/issues/2603
2022-04-10 06:56:12 +01:00
Andy Green
9011f913d5 netlink: always delete route if it exists
https://github.com/warmcat/libwebsockets/issues/2567
2022-03-15 10:28:09 +00:00
Sylvain Saunier
84956d280a route: fix nl groups and local ipv6 ads 2022-03-15 10:28:09 +00:00
Andy Green
ee15b82b6e cmake: unbreak LWS_WITH_SYS_STATE disabled build 2021-10-05 07:40:17 +01:00
Andy Green
4c4b2c5dcf libevent: use event_enable_debug_mode 2021-07-13 08:27:18 +01:00
Andy Green
5d8cf03221 logs: log contexts 2021-07-01 05:20:53 +01:00
Andy Green
8e76634ed3 logs: introduce log_cx 2021-07-01 05:20:53 +01:00
Andy Green
34afca321c netlink: hold in COLDPLUG until we actually have some routing table contents 2021-06-27 08:42:26 +01:00
Andrey Grafin
4341d756ae netlink: fix UB on RTM_NEWADDR/RTM_DELADDR
this patch makes ubsan (-fsanitize-undefined-trap-on-error) happy.

let's look at the following scenario:
1. netlink sends RTM_NEWADDR/RTM_DELADDR message
2. rops_handle_POLLIN_netlink() handles message attributes as RTA_*
3. rops_handle_POLLIN_netlink() finds RTA_PRIORITY attribute and
handles it as u32 value, but it's IFA_CACHEINFO attribute in reality
and payload holds another type
4. ubsan throws SIGTRAP

so, don't handle RTM_NEWADDR/RTM_DELADDR attributes as RTA_*
2021-05-26 14:07:27 +01:00
Yury Is
7247205e40 netlink: fix RTM_NEWLINK handling
https://github.com/warmcat/libwebsockets/issues/2287
2021-04-29 12:28:39 +01:00
Andy Green
ff8912ba96 netlink: make failure to bind nonfatal 2021-04-20 16:05:01 +01:00
Andy Green
e2f42387b7 route: assert if route table becomes full 2021-04-02 16:50:49 +01:00
Andy Green
f9c3d432a8 netlink: migrate to context
For SMP case, it was desirable to have a netlink listener per pt so they
could deal with pt-level changes in the pt's local service thread.  But
Linux restricts the process to just one netlink listener.

We worked around it by only listening on pt[0], this aligns us a bit more
with the reality and moves to a single routing table in the context.
There's still more to do for SMP case locking.
2021-03-08 20:43:19 +00:00
Andy Green
f42c97baa9 route: on change also check source address still extant 2021-02-17 11:39:12 +00:00
Andy Green
00b9ef09c0 netlink: back out lifecycle tag on netlink fail 2021-02-03 08:49:59 +00:00
Andy Green
d5618f6059 Wconversion: workarounds for CentOS7 2021-01-22 12:25:03 +00:00
Andy Green
c9731c5f17 type comparisons: fixes
This is a huge patch that should be a global NOP.

For unix type platforms it enables -Wconversion to issue warnings (-> error)
for all automatic casts that seem less than ideal but are normally concealed
by the toolchain.

This is things like passing an int to a size_t argument.  Once enabled, I
went through all args on my default build (which build most things) and
tried to make the removed default cast explicit.

With that approach it neither change nor bloat the code, since it compiles
to whatever it was doing before, just with the casts made explicit... in a
few cases I changed some length args from int to size_t but largely left
the causes alone.

From now on, new code that is relying on less than ideal casting
will complain and nudge me to improve it by warnings.
2021-01-05 10:56:38 +00:00
Andy Green
0ceba15d9c lws_lifecycle
This adds some new objects and helpers for keeping and logging
info on grouped allocations, a group is, eg, SS handles or client
wsis.

Allocated objects get a context-unique "tag" string intended to replace
%p / wsi pointers etc.  Pointers quickly become confusing when
allocations are freed and reused, the tag string won't repeat
until you produce 2^64 objects in a context.

In addition the tag string documents the object group, with prefixes
like "wsi-" or "vh-" and contain object-specific additional
information like the vhost name, address / port  or the role of the wsi.
At creation time the lws code can use a format string and args
to add whatever group-specific info makes sense, eg, a wsi bound
to a secure stream can also append the guid of the secure stream,
it's copied into the new object tag and so is still available
cleanly after the stream is destroyed if the wsi outlives it.
2021-01-04 05:26:50 +00:00
Andy Green
d330dbd76a wsi: unify base wsi creation function
A few different places want to create wsis and basically repeat their
own versions of the flow.  Let's unify it into one helper in wsi.c

Also require the context lock held (this only impacts LWS_MAX_SMP > 1)
2021-01-04 05:26:50 +00:00
Andy Green
2bcae2b3b6 context: refactor destroy flow 2020-11-28 10:58:38 +00:00
Andy Green
3549a94ce6 roles: compress role ops structs
role ops are usually only sparsely filled, there are currently 20
function pointers but several roles only fill in two.  No single
role has more than 14 of the ops.  On a 32/64 bit build this part
of the ops struct takes a fixed 80 / 160 bytes then.

First reduce the type of the callback reason part from uint16_t to
uint8_t, this saves 12 bytes unconditionally.

Change to a separate function pointer array with a nybble index
array, it costs 10 bytes for the index and a pointer to the
separate array, for 32-bit the cost is

2 + (4 x ops_used)

and for 64-bit

6 + (8 x ops_used)

for 2 x ops_used it means 32-bit: 10 vs 80 / 64-bit: 22 vs 160

For a typical system with h1 (9), h2 (14), listen (2), netlink (2),
pipe (1), raw_skt (3), ws (12), == 43 ops_used out of 140, it means
the .rodata for this reduced from 32-bit: 560 -> 174 (386 byte
saving) and 64-bit: 1120 -> 350 (770 byte saving)

This doesn't account for the changed function ops calling code, two
ways were tried, a preprocessor macro and explicit functions

For an x86_64 gcc 10 build with most options, release mode,
.text + .rodata

before patch:          553282
accessor macro:        552714 (568 byte saving)
accessor functions:    553674 (392 bytes worse than without patch)

therefore we went with the macros
2020-11-28 10:58:38 +00:00
Andy Green
643a001ed8 roles: netlink
This creates a role for RFC3549 Netlink monitoring.

If the OS supports it (currently, linux) then each pt creates a wsi
with the netlink role and dumps the current routing table at pt init.
It then maintains a cache of the routing table in each pt.

Upon routing table changes an SMD message is issued as an event, and
Captive Portal Detection is triggered.

All of the pt's current connections are reassessed for routability under
the changed routing table, those that no longer have a valid route or
gateway are closed.
2020-10-19 16:35:03 +01:00