diff options
author | David Cantrell <dcantrell@redhat.com> | 2007-04-27 19:53:15 +0000 |
---|---|---|
committer | David Cantrell <dcantrell@redhat.com> | 2007-04-27 19:53:15 +0000 |
commit | a42d5baeb856f7d153607a9394224a234419b7aa (patch) | |
tree | d456da24cdd17adbc83fef0eaee9883260ab90de /isys | |
parent | 24cca95f9f4c1ae3527118039b6d0f9ba8121dee (diff) | |
download | anaconda-a42d5baeb856f7d153607a9394224a234419b7aa.tar.gz anaconda-a42d5baeb856f7d153607a9394224a234419b7aa.tar.xz anaconda-a42d5baeb856f7d153607a9394224a234419b7aa.zip |
* rescue.py (startNetworking): Call the right functions to bring up
networking in rescue mode when booting from CD or DVD (#238080)
* isys/isys.py: Remove pumpNetDevice, replace with dhcpNetDevice that
can handle IPv4 and IPv6 (#238080).
* isys/isys.c (doDhcpNetDevice): Handle IPv4 and IPv6 stacks (#238080).
* isys/isys.c (doConfigNetDevice): Likewise.
* loader2/net.c (setupNetworkDeviceConfig): The netmask will never be
an IPv6 address.
Diffstat (limited to 'isys')
-rw-r--r-- | isys/isys.c | 88 | ||||
-rw-r--r-- | isys/isys.py | 43 |
2 files changed, 83 insertions, 48 deletions
diff --git a/isys/isys.c b/isys/isys.c index 07dcba192..951d20893 100644 --- a/isys/isys.c +++ b/isys/isys.c @@ -553,50 +553,50 @@ void init_isys(void) { PyDict_SetItemString(d, "EARLY_SWAP_RAM", PyInt_FromLong(EARLY_SWAP_RAM)); } -/* FIXME: add IPv6 support once the UI changes are made --dcantrell */ static PyObject * doConfigNetDevice(PyObject * s, PyObject * args) { - char * dev, * ip, * netmask; - char * gateway; + int i; + char *dev, *ipv4, *netmask, *ipv6, *prefix, *gateway; struct pumpNetIntf cfg; struct in_addr addr, nm, nw; struct in6_addr addr6; - if (!PyArg_ParseTuple(args, "ssss", &dev, &ip, &netmask, &gateway)) + if (!PyArg_ParseTuple(args, "ssssss", &dev, &ipv4, &netmask, + &ipv6, &prefix, &gateway)) return NULL; - memset(&cfg,'\0',sizeof(struct pumpNetIntf)); + memset(&cfg, '\0', sizeof(struct pumpNetIntf)); strncpy(cfg.device, dev, sizeof(cfg.device) - 1); - if (inet_pton(AF_INET, ip, &addr) >= 1) { - /* IPv4 */ - cfg.ip = ip_addr_in(&addr); - cfg.set |= PUMP_INTFINFO_HAS_IP; + /* IPv4 */ + if (inet_pton(AF_INET, ipv4, &addr) >= 1) { + cfg.ipv4 = ip_addr_in(&addr); if (inet_pton(AF_INET, netmask, &nm) >= 1) { cfg.netmask = ip_addr_in(&nm); - cfg.set |= PUMP_INTFINFO_HAS_NETMASK; - } - cfg.network = ip_addr_v4(ntohl((addr.s_addr) & nm.s_addr)); - nw = ip_in_addr(&cfg.network); - cfg.set |= PUMP_INTFINFO_HAS_NETWORK; + /* we have IP and netmask, calculate network and broadcast */ + cfg.network = ip_addr_v4(ntohl((addr.s_addr) & nm.s_addr)); + nw = ip_in_addr(&cfg.network); + cfg.broadcast = ip_addr_v4(ntohl(nw.s_addr | ~nm.s_addr)); + } + } - cfg.broadcast = ip_addr_v4(ntohl(nw.s_addr | ~nm.s_addr)); - cfg.set |= PUMP_INTFINFO_HAS_BROADCAST; - } else if (inet_pton(AF_INET6, ip, &addr) >= 1) { - /* IPv6 */ + /* IPv6 */ + if (inet_pton(AF_INET6, ipv6, &addr6) >= 1) { + cfg.ipv6 = ip_addr_in6(&addr6); - /* FIXME */ - return NULL; + if (strlen(prefix)) + i = atoi(prefix); + if (i > 0 && i <= 128) + cfg.ipv6_prefixlen = i; } + /* Global */ if (strlen(gateway)) { if (inet_pton(AF_INET, gateway, &addr) >= 1) { cfg.gateway = ip_addr_in(&addr); - cfg.set |= PUMP_NETINFO_HAS_GATEWAY; } else if (inet_pton(AF_INET6, gateway, &addr6) >= 1) { - /* FIXME */ - return NULL; + cfg.gateway = ip_addr_in6(&addr6); } } @@ -609,21 +609,18 @@ static PyObject * doConfigNetDevice(PyObject * s, PyObject * args) { return Py_None; } -/* FIXME: add IPv6 support once the UI changes are made --dcantrell */ static PyObject * doDhcpNetDevice(PyObject * s, PyObject * args) { - char * device; - char * dhcpclass = NULL; - char * r; + char *device, *r, *ipv4method = NULL, *ipv6method = NULL, *dhcpclass = NULL; + int useipv4, useipv6; char buf[47]; time_t timeout = 45; struct pumpNetIntf cfg; struct utsname kv; - /* FIXME: we call this from rescue mode, need to pass in what user wants */ - DHCP_Preference pref = DHCPv6_DISABLE; + DHCP_Preference pref = 0; ip_addr_t *tip; PyObject * rc; - if (!PyArg_ParseTuple(args, "s|s", &device, &dhcpclass)) + if (!PyArg_ParseTuple(args, "sisis|s", &device, &useipv4, &ipv4method, &useipv6, &ipv6method, &dhcpclass)) return NULL; if (dhcpclass == NULL) { @@ -632,23 +629,34 @@ static PyObject * doDhcpNetDevice(PyObject * s, PyObject * args) { else { int ret; ret = asprintf(&dhcpclass, "anaconda-%s %s %s", - kv.sysname,kv.release,kv.machine); + kv.sysname, kv.release, kv.machine); } } memset(&cfg, '\0', sizeof(cfg)); - strncpy(cfg.device, device, sizeof(cfg.device) - 1); + strcpy(cfg.device, device); + + if (!useipv4 || !strncmp(ipv4method, "manual", 6)) { + /* IPv4 disabled entirely -or- manual IPv4 config selected */ + pref |= DHCPv4_DISABLE; + } - r = pumpDhcpClassRun(&cfg, 0L, dhcpclass, pref, 0, timeout, NULL, 0L); - if (r) { - Py_INCREF(Py_None); - return Py_None; + if (useipv6 && !strncmp(ipv6method, "auto", 4)) { + /* IPv6 enabled -and- auto neighbor discovery selected */ + pref |= DHCPv6_DISABLE | DHCPv6_DISABLE_ADDRESSES; + } else if (!useipv6 || !strncmp(ipv6method, "manual", 6)) { + /* IPv6 disabled entirely -or- manual IPv6 config selected */ + pref |= DHCPv6_DISABLE; } - r = pumpSetupInterface(&cfg); - if (r) { - Py_INCREF(Py_None); - return Py_None; + pref |= DHCPv6_DISABLE_RESOLVER | DHCPv4_DISABLE_HOSTNAME_SET; + + if (!(pref & DHCPv4_DISABLE) || !(pref & DHCPv6_DISABLE)) { + r = pumpDhcpClassRun(&cfg, 0, dhcpclass, pref, 0, timeout, NULL, 0); + if (r) { + Py_INCREF(Py_None); + return Py_None; + } } if (cfg.numDns) { diff --git a/isys/isys.py b/isys/isys.py index 813de7976..43cde662c 100644 --- a/isys/isys.py +++ b/isys/isys.py @@ -541,9 +541,16 @@ def compareNetDevices(first, second): else: return 0 +# called from anaconda (basically rescue mode only) to configure an interface +# when we have collected all of the configuration information from the user +def configNetDevice(device, gateway): + devname = device.get('device') + ipv4 = device.get('ipaddr') + netmask = device.get('netmask') + ipv6 = device.get('ipv6addr') + prefix = device.get('ipv6prefix') -def configNetDevice(device, ip, netmask, gw): - return _isys.confignetdevice(device, ip, netmask, gw) + return _isys.confignetdevice(devname, ipv4, netmask, ipv6, prefix, gateway) def resetResolv(): return _isys.resetresolv() @@ -551,17 +558,37 @@ def resetResolv(): def setResolvRetry(count): return _isys.setresretry(count) +# called from anaconda to run DHCP (that's DHCP, DHCPv6, or auto neighbor +# discovery) on a particular interface def dhcpNetDevice(device, klass = None): # returns None on failure, "" if no nameserver is found, nameserver IP # otherwise + devname = device.get('device') + v4 = 0 + v6 = 0 + v4method = '' + v6method = '' + + if device.get('useipv4'): + v4 = 1 + if device.get('bootproto') == 'dhcp': + v4method = 'dhcp' + else: + v4method = 'manual' + + if device.get('useipv6'): + v6 = 1 + if device.get('ipv6_autoconf') == 'yes': + v6method = 'auto' + elif device.get('ipv6_autoconf') == 'no' and device.get('bootproto') == 'dhcp': + v6method = 'dhcp' + else: + v6method = 'manual' + if klass is not None: - return _isys.dhcpnetdevice(device, klass) + return _isys.dhcpnetdevice(devname, v4, v4method, v6, v6method, klass) else: - return _isys.dhcpnetdevice(device) - -def pumpNetDevice(device, klass = None): - return dhcpNetDevice(device, klass) - + return _isys.dhcpnetdevice(devname, v4, v4method, v6, v6method) def readXFSLabel_int(device): try: |