Commit Graph
1809 Commits
Author SHA1 Message Date
Yu Watanabe 073f438365 ndisc-option: sort options in sent message
To make the sent message reproducible.
2024-03-26 13:58:36 +00:00
Yu Watanabe 24578ce63a ndisc-option: introduce ndisc_option_remove() 2024-03-26 03:30:41 +09:00
Yu Watanabe 697c3693b3 ndisc-option: rename ndisc_option_get() -> ndisc_option_get_by_type()
Then, introduce more generic ndisc_option_get().
2024-03-26 03:30:41 +09:00
Yu WatanabeandEvgeny Vereshchagin cdb88ae4e5 fuzz: test NDisc packet with more low level functions
Also, test send back the test packet.

Co-authored-by: Evgeny Vereshchagin <evvers@ya.ru>
2024-03-18 23:19:44 +09:00
Yu Watanabe fcfb691fc1 icmp6-packet: expose icmp6_packet_get_header() 2024-03-18 23:18:43 +09:00
Yu Watanabe d112b4454c icmp6-util: drop unused icmp6_send_router_solicitation() 2024-03-18 22:52:29 +09:00
Yu Watanabe 349d51e7a1 sd-ndisc: use sd_ndisc_option and ndisc_send() 2024-03-18 22:52:29 +09:00
Yu Watanabe ca11446217 ndisc-option: introduce ndisc_send()
This will be used when sending Router Solicitation and Advertisement.
2024-03-18 22:52:29 +09:00
Yu Watanabe af0d593b32 ndisc-option: add a way to specify invalid or unsupported options
Mostly for testing.
2024-03-18 22:52:29 +09:00
Yu Watanabe 8430c4d91d test-ndisc-rs: send Router Solicit message before sending test packet 2024-03-18 22:52:29 +09:00
Yu Watanabe 5ed4c2b944 sd-dhcp-server: also save the server address and netmask to the leases file
And introduce a tiny helper to retrieve these information.
The function is not used at this time, but will be used later.
2024-03-15 04:15:10 +09:00
Yu Watanabe d47f83302e sd-dhcp-server: rearrange the parser of the leases file
No functional changes, just refactoring and preparation for later
commits.
2024-03-15 04:15:10 +09:00
Yu Watanabe 11b88419ae sd-dhcp-server: make sd_dhcp_server_set_lease_file() optionally take directory fd
Currently, though, no valid directory fd is passed to the function call.
Preparation for later commits.
2024-03-15 04:15:10 +09:00
Luca Boccassi 8e35076101 Merge pull request #31584 from yuwata/sd-ndisc-option-parser-cleanups
sd-ndisc: rewrite option parser
2024-03-13 23:06:50 +00:00
Evgeny Vereshchagin a96b4557cb fuzz: make sure DHCP client leases are loaded successfully
Now that fa3357b9e8 is merged the fuzz
target should no longer crash there.
2024-03-14 00:10:08 +09:00
Yu Watanabe 9ca04752cb sd-ndisc-router: adjust function names and type of returned value
- prefix length and preference should be fit in uint8_t, and actually
  the kernel and networkd uses uint8_t to store them.
- captive portal is now stored as a NUL-terminated string. Hence, it
  is not necessary to also provide its length.
2024-03-13 12:32:52 +09:00
Yu Watanabe b43c2221f6 sd-ndisc-router: introduce sd_ndisc_router_get_sender_mac()
The Router Advertisement option can take the MAC address of the sender.
Let's introduce a function to get it from the parsed options.
2024-03-13 12:32:52 +09:00
Yu Watanabe 0216c67269 ndisc-option: drop unused function 2024-03-13 12:32:52 +09:00
Yu Watanabe c0edd6b3b3 sd-ndisc-router: use ndisc_parse_options() and friends to parse Router Advertisement 2024-03-13 12:32:52 +09:00
Yu Watanabe a163404cc8 ndisc-option: introduce generic NDisc option parser
It is not used in this commit, but will be used for parsing NDisc
options in Router Advertisement message and friends.

The parser does mostly equivalent to what currently we do in
sd-ndisc-router.c. Several notable differences are:
- also perse source and target link-layer address,
- refuse multiple captive portals,
- check if the captive portal is in safe characters, as previously we
  checked that in networkd-ndisc.c,
- dedup prefixes, routes, and pref64,
- limit the total number of options, for safety.
2024-03-13 12:32:37 +09:00
Yu Watanabe dd6bbb3027 sd-ndisc: rename ndisc-protocol.[ch] -> ndisc-option.[ch] 2024-03-13 10:55:48 +09:00
Yu Watanabe 3fbade30a8 Merge pull request #31716 from evverx/fuzz-lease-save-load
fuzz: save/load DHCP client leases
2024-03-12 19:05:17 +09:00
Yu Watanabe 35b2c1b0c8 fuzz-dhcp-server: also test saving and loading lease file 2024-03-12 01:57:17 +09:00
Yu Watanabe 033f119756 sd-dhcp-server: introduce sd_dhcp_server_set_lease_file() and dhcp_server_{save,load}_leases().
The functionality is not used networkd yet in this commit, but will be
used in later commits.
2024-03-12 01:57:17 +09:00
Yu Watanabe aa8200e971 sd-dhcp-server: also expose lease expiration timestamp in realtime
Here, we use map_clock_usec_raw(), instead of map_clock_usec() to reduce
number of calls of now() -> clock_gettime().
2024-03-12 01:57:17 +09:00
Yu Watanabe b923ada838 sd-dhcp-server-lease: move functions to build json format
No functional change, just preparation for later commits.
2024-03-12 01:57:17 +09:00
Yu Watanabe 5a2f378362 sd-dhcp-server: refuse invalid hostname in request
Currently, the received hostname is not used for assigning an address to
the host, or options in the subsequent reply message. But, the parsed
hostname is exposed through DBus, and possibly Varlink in the future.
Let's ignore spurious hostname.
2024-03-12 01:57:17 +09:00
Yu Watanabe fa3357b9e8 dhcp-option: refuse control and non-UTF8 characters in string option
We oftem save parsed DHCP options into a file, or expose them
through DBus or Varlink. In such case, control characters or non-UTF8
characters may cause many kind of unexpected errors. In general, a DHCP
message that have string options with spurious characters is mostly
malformed or broken. Let's refuse them.

This also makes dhcp_option_parse_string() do not free 'ret' argument,
to follow our usual coding style. So, callers now need to free the
pre-exisitng string if necessary.

Fixes #31708.
2024-03-12 01:57:17 +09:00
Evgeny Vereshchagin 5801a18ed3 fuzz: save/load DHCP client leases
to make sure it more or less works with all sorts of leases.

Prompted by https://github.com/systemd/systemd/pull/30021#discussion_r1519123802
2024-03-11 09:41:44 +00:00
Evgeny Vereshchagin 1500b656cd fuzz: dump LLDP neighbors JSON too
to make sure all the fields are in more or less good shape.

It's a follow-up to https://github.com/systemd/systemd/pull/31583
2024-03-05 12:40:28 +09:00
Yu Watanabe eca7a4886d fuzz-lldp-rx: fuzz lldp_rx_build_neighbors_json()
Addresses https://github.com/systemd/systemd/pull/31583#discussion_r1509882453.
2024-03-02 13:52:28 +09:00
Yu Watanabe e2290a7775 sd-lldp: fix assignment of capabilities in JSON output
Follow-up for 329146a9ac.
2024-03-02 13:52:28 +09:00
Yu Watanabe 3807936cc5 Merge pull request #31502 from yuwata/network-lldp-json
network: support to dump LLDP neighbors in JSON format
2024-03-01 12:18:53 +09:00
Yu Watanabe ccb1ace77f sd-ndisc: drop unused sd_ndisc_router_get_raw() 2024-03-01 09:44:58 +09:00
Yu Watanabe f169c56447 sd-ndisc: use _packed_ attribute 2024-03-01 09:44:58 +09:00
Yu Watanabe bbb2a0fb41 icmp6-packet: check the alignment of struct nd_opt_hdr for safety
Addresses https://github.com/systemd/systemd/pull/31492#discussion_r1507481748.
2024-03-01 09:44:45 +09:00
Yu Watanabe ac23c5596e sd-lldp-rx: drop unused functions
These are not used anymore.
2024-03-01 09:40:26 +09:00
Tomáš Pecka 329146a9ac sd-lldp-rx: serialize LLDP neighbors to JSON format
Add functions serializing LLDP neighbors to JSON (JsonVariant).

The entry contains a chassis id, system name and port id of the remote
neighbor. Also it possibly contains an integer coding the enabled system
capabilities and port description.
2024-03-01 09:40:26 +09:00
Yu Watanabe 1e18e1aa11 Merge pull request #31492 from yuwata/icmp6-packet
sd-ndisc: introduce ICMP6Packet and relevant functions, and use them
2024-03-01 09:18:52 +09:00
Yu Watanabe 39af486a7f network/ndisc: drop redundant sd_ndisc_router_get_icmp6_ratelimit()
This effectively reverts 9175002864.

The retrans time field in RA message is for neighbor solicitation,
and the commit d4c8de21a0 makes the value
assigned to the correct sysctl property.

Let's deprecate the option, and drop the redundant functions.
2024-02-28 11:05:00 +00:00
Yu Watanabe 25413fbfc7 sd-ndisc: ignore Router Advertisement messages sent by the same interface 2024-02-28 11:40:50 +09:00
Yu Watanabe c34cb1d645 sd-ndisc: use ICMP6Packet and ndisc_option_parse() 2024-02-28 11:37:36 +09:00
Yu Watanabe 45edf75c61 sd-ndisc: introduce ndisc_option_parse() helper function 2024-02-28 11:26:52 +09:00
Yu Watanabe 07db3ac66c icmp6-packet: introduce ICMP6Packet and several relevant functions 2024-02-28 11:26:39 +09:00
Luca Boccassi 9529ae85f0 Merge pull request #31440 from yuwata/sd-ndisc-sd-radv-cleanups
sd-ndisc,sd-radv: several trivial cleanups
2024-02-25 13:07:53 +00:00
Yu Watanabe 9f0430b74b icmp6-util: make icmp6_receive() refuse packets without IPv6 sender address
Previously, the function supports packets without IPv6 sender address
for unit tests. However, now unit tests use their own version of
icmp6_receive(). Hence, let's make the check more strict.
2024-02-25 11:41:39 +00:00
Yu Watanabe 28eef15898 sd-ndisc: make callback takes arbitrary type of message
No functional change. Preparation for supporting Neighbor Advertisement
message.
2024-02-25 11:38:58 +00:00
Yu Watanabe a860df82b4 test: split out {dump,verify}_ra_message()
Then, let's not modify the global object.
2024-02-24 12:37:50 +09:00
Yu Watanabe 36653443f7 sd-radv: several cleanups
- split out radv_setup_recv_event(),
- slightly update log messages,
- use DIV_ROUND_UP(),
- use structured initializer more.

No functional change, just preparation for later commits.
2024-02-24 12:37:50 +09:00
Yu Watanabe 6a27ca08c6 sd-ndisc: several trivial cleanups
- update several log messages,
- use event_reset_time_relative(),
- split out ndisc_setup_recv_event() and ndisc_setup_timer().

No functional change, just refactoring and preparation for later commits.
2024-02-24 12:37:50 +09:00