This is roughly the same as my previous patch for supporting kickstart 'network --mtu-...', but broken into a series of smaller patches so you can actually see what's going on.
Patch 1-4 are all just cleanups, patch 5 adds --mtu.
dracut/parse-kickstart | 44 +++++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 21 deletions(-)
-w
This isn't how dracut configures the mtu; drop it. --- dracut/parse-kickstart | 7 ------- 1 file changed, 7 deletions(-)
diff --git a/dracut/parse-kickstart b/dracut/parse-kickstart index b5b30dd..8d488d3 100755 --- a/dracut/parse-kickstart +++ b/dracut/parse-kickstart @@ -230,13 +230,6 @@ def ksnet_to_dracut(args, lineno, net, bootdev=False): if ns: line.append("nameserver=%s" % ns)
- if net.mtu: - # XXX FIXME: dracut doesn't support mtu= (yet) - if net.device: - line.append("mtu=%s:%s" % (net.device, net.mtu)) - else: - line.append("mtu=%s" % net.mtu) - if bootdev: if net.device: line.append("bootdev=%s" % net.device)
They might be None, they might be "", they might be missing altogether. Consider all three possibilities. --- dracut/parse-kickstart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/dracut/parse-kickstart b/dracut/parse-kickstart index 8d488d3..5a4826d 100755 --- a/dracut/parse-kickstart +++ b/dracut/parse-kickstart @@ -194,7 +194,7 @@ def ksnet_to_dracut(args, lineno, net, bootdev=False): if is_mac(net.device): # this is a MAC - find the interface name mac = net.device net.device = find_devname(mac) - if net.device is None: # iface not active - pick a name for it + if not net.device: # iface not active - pick a name for it net.device = "ksdev0" # we only get called once, so this is OK line.append("ifname=%s:%s" % (net.device, mac.lower()))
@@ -207,7 +207,7 @@ def ksnet_to_dracut(args, lineno, net, bootdev=False): log.error("'%s': --bootproto=query is deprecated", " ".join(args)) elif net.bootProto == BOOTPROTO_STATIC: req = ("gateway", "netmask", "nameserver", "ip") - missing = ", ".join("--%s" % i for i in req if not hasattr(net, i)) + missing = ", ".join("--%s" % i for i in req if not getattr(net, i, "")) if missing: log.warn("line %u: network missing %s", lineno, missing) else:
If the device is None we should just leave it out of the final string we emit. --- dracut/parse-kickstart | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/dracut/parse-kickstart b/dracut/parse-kickstart index 5a4826d..15efacd 100755 --- a/dracut/parse-kickstart +++ b/dracut/parse-kickstart @@ -221,6 +221,9 @@ def ksnet_to_dracut(args, lineno, net, bootdev=False): ip="[{0.ipv6}]::{0.gateway}:{0.netmask}:" \ "{0.hostname}:{0.device}:none".format(net)
+ if net.device is None: + net.device = "" + if net.device and not ip.endswith(":none"): line.append("ip=%s:%s" % (net.device, ip)) else:
Since dracut allows simpler forms of the "ip=.." arg for autoconf, it makes sense to handle autoconf and static IP config differently. But it's kind of tricky to figure out which form the emitted argument is using, since we build it piece by piece.
So, let's make things clearer: handle autoconf separate from static IP, and put all the string formatting in one place. --- dracut/parse-kickstart | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-)
diff --git a/dracut/parse-kickstart b/dracut/parse-kickstart index 15efacd..0690e8e 100755 --- a/dracut/parse-kickstart +++ b/dracut/parse-kickstart @@ -190,6 +190,7 @@ def ksnet_to_dracut(args, lineno, net, bootdev=False): '''Translate the kickstart network data into dracut network data.''' line = [] ip="" + autoconf="dhcp" # dracut default
if is_mac(net.device): # this is a MAC - find the interface name mac = net.device @@ -200,34 +201,39 @@ def ksnet_to_dracut(args, lineno, net, bootdev=False):
# NOTE: dracut currently only does ipv4 *or* ipv6, so only one ip=arg.. if net.bootProto in (BOOTPROTO_DHCP, BOOTPROTO_BOOTP): - ip="dhcp" + autoconf = "dhcp" elif net.bootProto == BOOTPROTO_IBFT: - ip="ibft" + autoconf = "ibft" elif net.bootProto == BOOTPROTO_QUERY: log.error("'%s': --bootproto=query is deprecated", " ".join(args)) elif net.bootProto == BOOTPROTO_STATIC: + autoconf = "none" + ip = net.ip + # Static IPv4: check for missing items req = ("gateway", "netmask", "nameserver", "ip") missing = ", ".join("--%s" % i for i in req if not getattr(net, i, "")) if missing: log.warn("line %u: network missing %s", lineno, missing) - else: - ip="{0.ip}::{0.gateway}:{0.netmask}:" \ - "{0.hostname}:{0.device}:none".format(net) elif net.ipv6 == "auto": - ip="auto6" + autoconf = "auto6" elif net.ipv6 == "dhcp": - ip="dhcp6" + autoconf = "dhcp6" elif net.ipv6: - ip="[{0.ipv6}]::{0.gateway}:{0.netmask}:" \ - "{0.hostname}:{0.device}:none".format(net) + autoconf = "none" + ip = "[%s]" % net.ipv6
if net.device is None: net.device = ""
- if net.device and not ip.endswith(":none"): - line.append("ip=%s:%s" % (net.device, ip)) + # These argument forms are documented in dracut.kernel(7) + if autoconf == "none": + ipstr = "ip={ip}::{net.gateway}:{net.netmask}:{net.hostname}:{net.device}:{autoconf}".format(ip=ip, autoconf=autoconf, net=net) + elif net.device: + ipstr = "ip={net.device}:{autoconf}".format(net=net, autoconf=autoconf) else: - line.append("ip=%s" % ip) + ipstr = "ip={autoconf}".format(autoconf=autoconf) + + line.append(ipstr)
for ns in net.nameserver.split(","): if ns:
Pass the MTU argument along to dracut in the expected way. --- dracut/parse-kickstart | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/dracut/parse-kickstart b/dracut/parse-kickstart index 0690e8e..994eb07 100755 --- a/dracut/parse-kickstart +++ b/dracut/parse-kickstart @@ -227,9 +227,9 @@ def ksnet_to_dracut(args, lineno, net, bootdev=False):
# These argument forms are documented in dracut.kernel(7) if autoconf == "none": - ipstr = "ip={ip}::{net.gateway}:{net.netmask}:{net.hostname}:{net.device}:{autoconf}".format(ip=ip, autoconf=autoconf, net=net) - elif net.device: - ipstr = "ip={net.device}:{autoconf}".format(net=net, autoconf=autoconf) + ipstr = "ip={ip}::{net.gateway}:{net.netmask}:{net.hostname}:{net.device}:{autoconf}:{net.mtu}".format(ip=ip, autoconf=autoconf, net=net) + elif net.device or net.mtu: + ipstr = "ip={net.device}:{autoconf}:{net.mtu}".format(net=net, autoconf=autoconf) else: ipstr = "ip={autoconf}".format(autoconf=autoconf)
On Wed, Aug 29, 2012 at 02:07:17PM -0400, Will Woods wrote:
Pass the MTU argument along to dracut in the expected way.
dracut/parse-kickstart | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/dracut/parse-kickstart b/dracut/parse-kickstart index 0690e8e..994eb07 100755 --- a/dracut/parse-kickstart +++ b/dracut/parse-kickstart @@ -227,9 +227,9 @@ def ksnet_to_dracut(args, lineno, net, bootdev=False):
# These argument forms are documented in dracut.kernel(7) if autoconf == "none":
ipstr = "ip={ip}::{net.gateway}:{net.netmask}:{net.hostname}:{net.device}:{autoconf}".format(ip=ip, autoconf=autoconf, net=net)
- elif net.device:
ipstr = "ip={net.device}:{autoconf}".format(net=net, autoconf=autoconf)
ipstr = "ip={ip}::{net.gateway}:{net.netmask}:{net.hostname}:{net.device}:{autoconf}:{net.mtu}".format(ip=ip, autoconf=autoconf, net=net)
- elif net.device or net.mtu:
else: ipstr = "ip={autoconf}".format(autoconf=autoconf)ipstr = "ip={net.device}:{autoconf}:{net.mtu}".format(net=net, autoconf=autoconf)
I'm not clear on whether mtu could be set without device, but I think the above could end up with ip=None:... if net.device isn't set. And the same goes for mtu if it isn't set.
anaconda-patches@lists.fedorahosted.org