-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
network: DHCPv4 client- add support to send arbitary option and data #13663
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So... I think this is needlessly complicated.
Instead of defining a separate section, what about the following:
DHCPOption=NNN: XYZXYZ
The syntax would be: a number, a colon, and a c-escaped string.
This would simplify parsing a lot, because it would be possible to have the whole option at once, without the need to define a separate section and whatnot.
This will be also much more concise, so nicer for the user.
If the same option is defined multiple times, that's OK. Just keep them in a list and attach in the order specified by the user. For some cases, the order may matter, and since it's simpler to keep the order, let's just do that.
This will allow the hashing and comparison functions and separate DHCPOption structure to be dropped.
Oh, and just please say |
done
Do we have such such parsing before ? I thought of that dropped as could not find. |
Pretty much any option which takes multiple values. SystemCallFilter= as good example. |
|
https://tools.ietf.org/html/rfc2131#section-3.5 says:
and https://tools.ietf.org/html/rfc2132#section-9 doesn't list any options which would be allowed multiple times. So yeah, it seems that you are right, and only allowing each given option once would be appropriate. So... you may either use a OrderedHashmap to store the options (option number => sd_dhcp_option), or a array. If you use a hashmap, then the hashing function should only use the option number ( |
b09de2e
to
7fd2b80
Compare
Thanks for review @keszybz . Updated. |
7fd2b80
to
d6ecdae
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks better, but there's still confusion as to if options are allowed multiple times. The sort order is also lost.
470ed1e
to
774706d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure that multiple option assignments should be allowed in one line?
I think it'd be simpler to always require just one option setting per line.
Of course you only want to consider the first one. The question is whether to allow one word on the rhs or multiple words.
I would consider one assignment per line because the main use-case is binary data as values. But I'm not sure what the best way to encode this is.
Was not the previous code doing that ? Now I am confused . : separation has a issue. How you send the IP addresses ? May be just consider the first one .
If I understand you correctly, you ask about how to use multiple IP addresses as the value of a single option. I think we do not have to consider this case, as no official options consists of the DHCP client sending IP addresses and if it is a proprietary extension, you would have to encode this as single bytes.
I would rather provide a more convenient way to encode a byte-string than to think of any possible encoding of IPs, strings, integers, etc.
774706d
to
28770a9
Compare
@keszybz and @ssahani I updated this PR. PTAL. I will try to add a test case. @ssahani Your original version is saved at https://github.com/yuwata/systemd/commits/pr-13663-backup. If you do not like this. Please revert this and restore your original one. |
@yuwata Thanks for working on it. LGTM. |
28770a9
to
c898fe9
Compare
Hmm, dnsmasq does not logs the sent data. @ssahani Do you have any idea to test this PR? |
Yes we can test it tcpdump . Please see https://src.fedoraproject.org/fork/ssahani/rpms/lldpad/c/451044af05e03da3ac08b154efbb8d0915e7bb73 We have to create a service [Unit]
Description=TCPDumpd
After=multi-user.target network.target
[Service]
Type=simple
ExecStart=/usr/sbin/tcpdump -pnnli port 67 or port 68 -e -n -vvv -w "/tmp/dhcp-tcp-dump.pcap"
[Install]
WantedBy=multi-user.target def CaptureLLDPPackets(self):
def FindLLDPFieldsinTCPDump(self, **kwargs):
"""Look attributes in lldpad logs."""
ontents = subprocess.check_output(['tcpdump', '-v', '-r', LLDPAD_TCP_DUMP_FILE]).rstrip().decode('utf-8')
if kwargs is not None:
for key in kwargs:
self.assertRegex(contents, kwargs[key]) |
@ssahani Excellent! But that needs relatively huge work. Let's do that in another PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, this version is much more consistent then the previous ones.
We only allow one setting for a given option number, and use the earliest value. Is this intentional?
c898fe9
to
7acb770
Compare
@keszybz Thank you for the review. I've force-pushed a revised version. I hope all your comments are addressed.
Yes, based on your investigation #13663 (comment). |
Thanks, I'll look again tomorrow.
Yep, one setting is OK. But why take the earliest value? This goes against our usual override rules:
→ I'd expect "foo:barbar bar:foo" to be the options sent to the server. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Almost there ;)
OK, let's mereg. |
Not there yet... https://github.com/egberts/systemd-dhclient Some of the limitation of systemd's DHCP client is that there is no DHCP-Options. Hence the need to use ISC DHCP client despite pervasiveness of systemd's own built-in DHCP client. I also like Dynamic DNS update which is those fancy communication between BIND9 DNS server and DHCP server. systemd-ddns is also nice but it didn't have other things (described in next section). Again, my gateway had too much invested into the usages of ISC BIND9 and ISC DHCP server. systemd-dhcp-server also cannot do custom database interfaces. systemd-dhcp-server cannot do dynamic hostname replacement regardless of MAC address. systemd-dhcp-server cannot do failover and high-redundancy. |
Maybe these issues you say, @egberts, could be written as a Github issue each one, don't you think? |
Maybe these issues you say, @egberts, could be written as a Github issue each one, don't you think?
It’s a huge undertaking whereas OID parser is needed.
Much easier to fallback on good ol’ trusty ISC DHCP.
|
Closes #5134