Yu Watanabe
f63e09ef75
network: use bus_error_message()
2020-12-02 20:31:39 +09:00
Yu Watanabe
53ec5dd028
network: use IN_SET() macro
...
Follow-up for 1d370b2c18
.
2020-11-30 12:41:41 +09:00
Jörg Thalheim
1d370b2c18
networkd/dhcp6: allow layer3 devices without MAC
...
Devices with multicast but without mac addresses i.e. tun devices
are not getting setuped correctly:
$ ip tuntap add mode tun dev tun0
$ ip addr show tun0
16: tun0: <NO-CARRIER,POINTOPOINT,MULTICAST,NOARP,UP> mtu 1500 qdisc fq_codel state DOWN group default qlen 500
link/none
$ cat /etc/systemd/network/tun0.network
[Match]
Name = tun0
[Network]
Address=192.168.1.1/32
$ ./systemd-networkd
tun0: DHCP6 CLIENT: Failed to set identifier: Invalid argument
tun0: Failed
2020-11-23 13:56:48 +01:00
Yu Watanabe
db9ecf0501
license: LGPL-2.1+ -> LGPL-2.1-or-later
2020-11-09 13:23:58 +09:00
Yu Watanabe
22d37e5df6
network: introduce network_adjust_dhcp()
2020-10-15 07:06:58 +09:00
Frantisek Sumsal
d7a0f1f4f9
tree-wide: assorted coccinelle fixes
2020-10-09 15:02:23 +02:00
Yu Watanabe
256c75fd1f
network: move DUID related functions
2020-10-07 02:50:50 +09:00
Yu Watanabe
67c311abd3
network: unify link_dhcp{4,6}_enabled()
2020-10-07 02:50:50 +09:00
Yu Watanabe
d96edb2c6e
network: downgrade log level in conf parsers
2020-07-17 00:40:09 +09:00
Zbigniew Jędrzejewski-Szmek
de7fef4b6e
tree-wide: use set_ensure_put()
...
Patch contains a coccinelle script, but it only works in some cases. Many
parts were converted by hand.
Note: I did not fix errors in return value handing. This will be done separate
to keep the patch comprehensible. No functional change is intended in this
patch.
2020-06-22 16:32:37 +02:00
Yu Watanabe
8dd91cb55b
network: drop an unused function
2020-06-02 17:06:01 +09:00
Yu Watanabe
c24dd73952
network: move DHCPv6 related conf parsers to networkd-dhcp6.c
2020-06-02 17:06:00 +09:00
Yu Watanabe
bdad94d0d6
network: set both dhcp_route_metric and dhcp6_route_metric by DHCP.RouteMetric= for backward compatibility
...
But [DHCPv4] or [DHCPv6] section take precedence.
This also update so for UseDNS= and UseNTP=.
2020-06-02 17:05:49 +09:00
Susant Sahani
b4ccc5de7d
network: Inroduce DHCP6- send vendor options
...
network: Inroduce DHCP6- send vendor options
```
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| OPTION_VENDOR_OPTS | option-len |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| enterprise-number |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
. .
. vendor-option-data .
. .
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
```
```
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| sub-opt-code | sub-option-len |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
. .
. sub-option-data .
. .
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Figure 31: Vendor-specific Options Format
sub-opt-code The code for the sub-option. A 2-octet
field.
sub-option-len An unsigned integer giving the length of the
sub-option-data field in this sub-option in
octets. A 2-octet field.
sub-option-data The data area for the sub-option. The
length, in octets, is specified by
sub-option-len.
```
2020-05-29 13:37:57 +02:00
Susant Sahani
1eb73422f2
network: Fix crash when SendOption= is invalid
...
```
p11-kit-0.23.20-1.fc32.x86_64 pam-1.3.1-26.fc33.x86_64 xz-libs-5.2.5-1.fc33.x86_64 zlib-1.2.11-21.fc32.x86_64
(gdb) bt
lvalue=0x560e10 "SendOption", ltype=2, rvalue=0x560e1b "11:string", data=0x561e20, userdata=0x561cd0) at ../src/network/networkd-dhcp-common.c:580
table=0x4392e0 <network_network_gperf_lookup>, section=0x560ef0 "DHCPv4", section_line=14, lvalue=0x560e10 "SendOption", rvalue=0x560e1b "11:string", flags=CONFIG_PARSE_WARN,
userdata=0x561cd0) at ../src/shared/conf-parser.c:132
lookup=0x7ffff7d2f76d <config_item_perf_lookup>, table=0x4392e0 <network_network_gperf_lookup>, flags=CONFIG_PARSE_WARN, section=0x7fffffffc9f8, section_line=0x7fffffffc9a0,
section_ignored=0x7fffffffc99d, l=0x560e10 "SendOption", userdata=0x561cd0) at ../src/shared/conf-parser.c:270
lookup=0x7ffff7d2f76d <config_item_perf_lookup>, table=0x4392e0 <network_network_gperf_lookup>, flags=CONFIG_PARSE_WARN, userdata=0x561cd0) at ../src/shared/conf-parser.c:395
lookup=0x7ffff7d2f76d <config_item_perf_lookup>, table=0x4392e0 <network_network_gperf_lookup>, flags=CONFIG_PARSE_WARN, userdata=0x561cd0) at ../src/shared/conf-parser.c:452
dropin_dirname=0x7fffffffcbd0 "veth99.network.d", sections=0x4f3a18 "Match", lookup=0x7ffff7d2f76d <config_item_perf_lookup>, table=0x4392e0 <network_network_gperf_lookup>,
flags=CONFIG_PARSE_WARN, userdata=0x561cd0) at ../src/shared/conf-parser.c:511
(gdb) q
A debugging session is active.
Inferior 1 [process 118718] will be killed.
```
```
$ printf '[DHCPv4]\nSendOption=1:uint8' >crash
$ ./out/fuzz-network-parser ./crash
INFO: Seed: 1158717610
INFO: Loaded 2 modules (199728 inline 8-bit counters): 136668 [0x7faf3e91a930, 0x7faf3e93bf0c), 63060 [0xadf190, 0xaee7e4),
INFO: Loaded 2 PC tables (199728 PCs): 136668 [0x7faf3e93bf10,0x7faf3eb51cd0), 63060 [0xaee7e8,0xbe4d28),
./out/fuzz-network-parser: Running 1 inputs 1 time(s) each.
Running: ./crash
Assertion 's' failed at src/basic/parse-util.c:458, function int safe_atou8(const char *, uint8_t *)(). Aborting.
==5588== ERROR: libFuzzer: deadly signal
#0 0x51811e in __sanitizer_print_stack_trace (/home/vagrant/systemd/out/fuzz-network-parser+0x51811e)
#1 0x46b921 in fuzzer::PrintStackTrace() (/home/vagrant/systemd/out/fuzz-network-parser+0x46b921)
#2 0x44ded6 in fuzzer::Fuzzer::CrashCallback() (.part.0) (/home/vagrant/systemd/out/fuzz-network-parser+0x44ded6)
#3 0x44df9d in fuzzer::Fuzzer::StaticCrashSignalCallback() (/home/vagrant/systemd/out/fuzz-network-parser+0x44df9d)
#4 0x7faf3d6d7b1f (/lib64/libpthread.so.0+0x14b1f)
#5 0x7faf3d3c2624 in raise (/lib64/libc.so.6+0x3c624)
#6 0x7faf3d3ab8d8 in abort (/lib64/libc.so.6+0x258d8)
#7 0x7faf3e12593a in log_assert_failed_realm /home/vagrant/systemd/build/../src/basic/log.c:819:9
#8 0x7faf3e140ce1 in safe_atou8 /home/vagrant/systemd/build/../src/basic/parse-util.c:458:9
#9 0x68089c in config_parse_dhcp_send_option /home/vagrant/systemd/build/../src/network/networkd-dhcp-common.c:517:21
#10 0x7faf3debed4e in next_assignment /home/vagrant/systemd/build/../src/shared/conf-parser.c:132:32
#11 0x7faf3deb7783 in parse_line /home/vagrant/systemd/build/../src/shared/conf-parser.c:270:16
#12 0x7faf3deb606c in config_parse /home/vagrant/systemd/build/../src/shared/conf-parser.c:395:21
#13 0x7faf3deb85ee in config_parse_many_files /home/vagrant/systemd/build/../src/shared/conf-parser.c:452:21
#14 0x7faf3deb8c57 in config_parse_many /home/vagrant/systemd/build/../src/shared/conf-parser.c:511:16
#15 0x57c2eb in network_load_one /home/vagrant/systemd/build/../src/network/networkd-network.c:470:13
#16 0x543490 in LLVMFuzzerTestOneInput /home/vagrant/systemd/build/../src/network/fuzz-network-parser.c:26:16
#17 0x44e3e8 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) (/home/vagrant/systemd/out/fuzz-network-parser+0x44e3e8)
#18 0x433505 in fuzzer::RunOneTest(fuzzer::Fuzzer*, char const*, unsigned long) (/home/vagrant/systemd/out/fuzz-network-parser+0x433505)
#19 0x43c449 in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) (/home/vagrant/systemd/out/fuzz-network-parser+0x43c449)
#20 0x42c4a6 in main (/home/vagrant/systemd/out/fuzz-network-parser+0x42c4a6)
#21 0x7faf3d3ad1a2 in __libc_start_main (/lib64/libc.so.6+0x271a2)
#22 0x42c4fd in _start (/home/vagrant/systemd/out/fuzz-network-parser+0x42c4fd)
NOTE: libFuzzer has rudimentary signal handlers.
Combine libFuzzer with AddressSanitizer or similar for better crash reports.
SUMMARY: libFuzzer: deadly signal
```
2020-05-22 11:57:22 +02:00
Susant Sahani
ed0d1b2e99
network: DHCPv6 - Add support to send vendor class information
...
Frame 1: 177 bytes on wire (1416 bits), 177 bytes captured (1416 bits) on interface veth-peer, id 0
Ethernet II, Src: 1e:04:f8:b8:2f:d4 (1e:04:f8:b8:2f:d4), Dst: IPv6mcast_01:00:02 (33:33:00:01:00:02)
Internet Protocol Version 6, Src: fe80::1c04:f8ff:feb8:2fd4, Dst: ff02::1:2
User Datagram Protocol, Src Port: 546, Dst Port: 547
DHCPv6
Message type: Solicit (1)
Transaction ID: 0x5ca46b
Rapid Commit
Identity Association for Non-temporary Address
Fully Qualified Domain Name
Vendor Class
Option: Vendor Class (16)
Length: 23
Value: 0000ab11000048656c6c6f3a686f773a6172653a796f75
Enterprise ID: Tom Gundersen (systemd) (43793)
vendor-class-data: Hello:how:are:you
Identity Association for Prefix Delegation
Option Request
Client Identifier
Elapsed time
2020-05-20 07:58:03 +02:00
Susant Sahani
ffed0205c7
DHCP: Use UINT8_MAX instead of 255
2020-05-19 11:48:37 +02:00
Susant Sahani
f37f2a6b8a
network: DHCPv6 - Add support to send user class
...
Frame 115: 171 bytes on wire (1368 bits), 171 bytes captured (1368 bits) on interface veth-peer, id 0
Ethernet II, Src: 1e:04:f8:b8:2f:d4 (1e:04:f8:b8:2f:d4), Dst: IPv6mcast_01:00:02 (33:33:00:01:00:02)
Internet Protocol Version 6, Src: fe80::1c04:f8ff:feb8:2fd4, Dst: ff02::1:2
User Datagram Protocol, Src Port: 546, Dst Port: 547
DHCPv6
Message type: Solicit (1)
Transaction ID: 0x673257
Rapid Commit
Option: Rapid Commit (14)
Length: 0
Identity Association for Non-temporary Address
Option: Identity Association for Non-temporary Address (3)
Length: 12
Value: d0cc94090000000000000000
IAID: d0cc9409
T1: 0
T2: 0
Fully Qualified Domain Name
Option: Fully Qualified Domain Name (39)
Length: 6
Value: 01045a657573
0000 0... = Reserved: 0x00
.... .0.. = N bit: Server should perform DNS updates
.... ..0. = O bit: Server has not overridden client's S bit preference
.... ...1 = S bit: Server should perform forward DNS updates
Client FQDN: Zeus
User Class
Option: User Class (15)
Length: 17
Value: 000f68656c6c6f30313233343031323334
Identity Association for Prefix Delegation
Option: Identity Association for Prefix Delegation (25)
Length: 12
Value: d0cc94090000000000000000
IAID: d0cc9409
T1: 0
T2: 0
Option Request
Option: Option Request (6)
Length: 10
Value: 001700180038001f000e
Requested Option code: DNS recursive name server (23)
Requested Option code: Domain Search List (24)
Requested Option code: NTP Server (56)
Requested Option code: Simple Network Time Protocol Server (31)
Requested Option code: Rapid Commit (14)
Client Identifier
Option: Client Identifier (1)
Length: 14
Value: 00020000ab11d258482fc7eee651
DUID: 00020000ab11d258482fc7eee651
DUID Type: assigned by vendor based on Enterprise number (2)
Enterprise ID: Tom Gundersen (systemd) (43793)
Identifier: d258482fc7eee651
Elapsed time
Option: Elapsed time (8)
Length: 2
Value: 0bd0
Elapsed time: 30240ms
2020-05-19 11:48:30 +02:00
Susant Sahani
35f6a5cb44
network: DHCPv6 - Add support set arbitary request options
2020-05-17 11:18:29 +02:00
Andrew Doran
e7d5fe17db
DHCP client: make SendOption work for DHCPv6 too.
2020-05-11 16:31:08 +02:00
Susant Sahani
3175a8c21b
network: DHCPv6 Add support to send MUD URL
2020-04-01 17:01:12 +02:00
Yu Watanabe
732e3a6104
network: accept NUL character in SendOption=
...
Closes #14609 .
2020-01-27 19:58:10 +09:00
Yu Watanabe
83b56c70e6
network: fix segfault in parsing SendOption=
...
Fixes #14283 .
2019-12-10 01:28:09 +09:00
Yu Watanabe
3db7d5d2bf
network: fix double free()
2019-11-28 19:50:45 +01:00
Yu Watanabe
0e96961d62
network: unify config_parse_dhcp_server_option_data() and config_parse_dhcp_send_option()
2019-11-18 23:39:03 +09:00
Yu Watanabe
2e5580a8c1
network: rename DHCPRawOption to DHCPOptionDataType
...
And moves the definition from networkd-dhcp-server.[ch] to networkd-dhcp-common.[ch].
2019-11-17 23:00:11 +09:00
Susant Sahani
2805536bff
network: DHCPv6 client add support for prefix delegation hint
...
Add support for prefix hint lenth and prefix hint address
```
Frame 43: 177 bytes on wire (1416 bits), 177 bytes captured (1416 bits) on interface 0
Ethernet II, Src: f6:c1:08:4d:45:f1 (f6:c1:08:4d:45:f1), Dst: IPv6mcast_01:00:02 (33:33:00:01:00:02)
Internet Protocol Version 6, Src: fe80::d250:c82:7f6e:28d6, Dst: ff02::1:2
User Datagram Protocol, Src Port: 546, Dst Port: 547
DHCPv6
Message type: Solicit (1)
Transaction ID: 0x5c7902
Rapid Commit
Identity Association for Non-temporary Address
Fully Qualified Domain Name
Identity Association for Prefix Delegation
Option: Identity Association for Prefix Delegation (25)
Length: 41
Value: 1b97b1690000000000000000001a0019ffffffffffffffff…
IAID: 1b97b169
T1: 0
T2: 0
IA Prefix
Option: IA Prefix (26)
Length: 25
Value: ffffffffffffffff3c000000000000000000000000000000…
Preferred lifetime: infinity
Valid lifetime: infinity
Prefix length: 60
Prefix address: ::
Option Request
Client Identifier
Elapsed time
```
2019-10-01 23:52:40 +09:00
Susant Sahani
299d578f7f
network: DHCP server Add support to transmit SIP server
...
1. DHCP server trasmit
2. Client parses and saves in leases
Implements http://www.rfc-editor.org/rfc/rfc3361.txt
```
Frame 134: 348 bytes on wire (2784 bits), 348 bytes captured (2784 bits) on interface 0
Ethernet II, Src: 42:65:85:d6:4e:32 (42:65:85:d6:4e:32), Dst: 1e:04:f8:b8:2f:d4 (1e:04:f8:b8:2f:d4)
Internet Protocol Version 4, Src: 192.168.5.1, Dst: 192.168.5.11
User Datagram Protocol, Src Port: 67, Dst Port: 68
Dynamic Host Configuration Protocol (ACK)
Message type: Boot Reply (2)
Hardware type: Ethernet (0x01)
Hardware address length: 6
Hops: 0
Transaction ID: 0x7cc87cb4
Seconds elapsed: 0
Bootp flags: 0x0000 (Unicast)
Client IP address: 0.0.0.0
Your (client) IP address: 192.168.5.11
Next server IP address: 0.0.0.0
Relay agent IP address: 0.0.0.0
Client MAC address: 1e:04:f8:b8:2f:d4 (1e:04:f8:b8:2f:d4)
Client hardware address padding: 00000000000000000000
Server host name not given
Boot file name not given
Magic cookie: DHCP
Option: (53) DHCP Message Type (ACK)
Length: 1
DHCP: ACK (5)
Option: (51) IP Address Lease Time
Length: 4
IP Address Lease Time: (3600s) 1 hour
Option: (1) Subnet Mask (255.255.255.0)
Length: 4
Subnet Mask: 255.255.255.0
Option: (3) Router
Length: 4
Router: 192.168.5.1
Option: (6) Domain Name Server
Length: 4
Domain Name Server: 192.168.5.1
Option: (42) Network Time Protocol Servers
Length: 4
Network Time Protocol Server: 192.168.1.1
Option: (120) SIP Servers <=====here
Length: 9
SIP Server Encoding: IPv4 Address (1)
SIP Server Address: 192.168.1.1
SIP Server Address: 192.168.5.2
Option: (101) TCode
Length: 13
TZ TCode: Europe/Berlin
Option: (54) DHCP Server Identifier (192.168.5.1)
Length: 4
DHCP Server Identifier: 192.168.5.1
Option: (255) End
Option End: 255
```
```
cat /run/systemd/netif/state ✔ ⚡ 3148 16:40:51
OPER_STATE=routable
CARRIER_STATE=carrier
ADDRESS_STATE=routable
DNS=192.168.94.2 192.168.5.1
NTP=192.168.5.1
SIP=192.168.1.1 192.168.5.2
```
aa
2019-09-20 21:22:23 +09:00
Yu Watanabe
2d79289525
network: rename AddressFamilyBoolean -> AddressFamily
...
We usually do not call an extended boolean as XxxBoolean.
2019-08-16 22:02:17 +09:00
Susant Sahani
426588bc63
network: fix DHCP route rumber parsing.
2019-07-24 18:06:30 +05:30
Yu Watanabe
4f7331a85e
network: rename [DHCP] section to [DHCPv4]
...
To keep the backward compatibility broken by the previous commit.
2019-07-10 17:33:09 +09:00
Yu Watanabe
ca5ad760a5
network: move conf parsers and function prototypes
2019-06-30 04:45:56 +09:00