commit linuxrc for openSUSE:Factory
Hello community, here is the log from the commit of package linuxrc for openSUSE:Factory checked in at 2014-07-24 06:58:36 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/linuxrc (Old) and /work/SRC/openSUSE:Factory/.linuxrc.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "linuxrc" Changes: -------- --- /work/SRC/openSUSE:Factory/linuxrc/linuxrc.changes 2014-07-21 10:35:30.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.linuxrc.new/linuxrc.changes 2014-07-24 06:58:43.000000000 +0200 @@ -1,0 +2,15 @@ +Wed Jul 23 11:25:24 CEST 2014 - snwint@suse.de + +- fix network setup +- 5.0.3 + +------------------------------------------------------------------- +Tue Jul 22 08:00:13 CEST 2014 - snwint@suse.de + +- use wicked to setup static network config +- support ptp setups and accept global default netmask value for all ips +- put copy of old-style config into new config +- better internal logging of network config entries +- 5.0.2 + +------------------------------------------------------------------- Old: ---- linuxrc-5.0.1.tar.xz New: ---- linuxrc-5.0.3.tar.xz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ linuxrc.spec ++++++ --- /var/tmp/diff_new_pack.mxev6X/_old 2014-07-24 06:58:44.000000000 +0200 +++ /var/tmp/diff_new_pack.mxev6X/_new 2014-07-24 06:58:44.000000000 +0200 @@ -25,9 +25,9 @@ Summary: SUSE Installation Program License: GPL-3.0+ Group: System/Boot -Version: 5.0.1 +Version: 5.0.3 Release: 0 -Source: linuxrc-5.0.1.tar.xz +Source: linuxrc-5.0.3.tar.xz BuildRoot: %{_tmppath}/%{name}-%{version}-build %description ++++++ linuxrc-5.0.1.tar.xz -> linuxrc-5.0.3.tar.xz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/linuxrc-5.0.1/VERSION new/linuxrc-5.0.3/VERSION --- old/linuxrc-5.0.1/VERSION 2014-07-18 15:28:06.000000000 +0200 +++ new/linuxrc-5.0.3/VERSION 2014-07-23 11:25:14.000000000 +0200 @@ -1 +1 @@ -5.0.1 +5.0.3 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/linuxrc-5.0.1/auto2.c new/linuxrc-5.0.3/auto2.c --- old/linuxrc-5.0.1/auto2.c 2014-07-18 14:54:13.000000000 +0200 +++ new/linuxrc-5.0.3/auto2.c 2014-07-21 13:23:41.000000000 +0200 @@ -597,18 +597,18 @@ { if(!net_config_needed(0)) return; - check_ptp(); + check_ptp(NULL); if( ((net_config_mask() & 3) == 3) || (config.net.ptp && ((net_config_mask() & 1) == 1)) ) { /* we have IP & netmask (or just IP for PTP devices) */ config.net.configured = nc_static; - /* looks a bit weird, but we need it here for net_activate_ns() */ + /* looks a bit weird, but we need it here for net_static() */ if(!config.net.device) str_copy(&config.net.device, config.netdevice); if(!config.net.device) { util_update_netdevice_list(NULL, 1); if(config.net.devices) str_copy(&config.net.device, config.net.devices->key); } - if(net_activate_ns()) { + if(net_static()) { fprintf(stderr, "net activation failed\n"); config.net.configured = nc_none; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/linuxrc-5.0.1/changelog new/linuxrc-5.0.3/changelog --- old/linuxrc-5.0.1/changelog 2014-07-18 15:28:08.000000000 +0200 +++ new/linuxrc-5.0.3/changelog 2014-07-23 11:25:17.000000000 +0200 @@ -1,4 +1,13 @@ -2014-07-18: HEAD +2014-07-23: HEAD + - fix network setup + +2014-07-21: 5.0.2 + - use wicked to setup static network config + - support ptp setups and accept global default netmask value for all ips + - put copy of old-style config into new config + - better internal logging of network config entries + +2014-07-18: 5.0.1 - continue network code reworking - fix network re-config (bnc #887841) - move network setup into separate menu item diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/linuxrc-5.0.1/file.c new/linuxrc-5.0.3/file.c --- old/linuxrc-5.0.1/file.c 2014-07-18 14:19:48.000000000 +0200 +++ new/linuxrc-5.0.3/file.c 2014-07-21 12:48:17.000000000 +0200 @@ -664,6 +664,9 @@ break; case key_hostip: + str_copy(&config.ifcfg.manual->type, "static"); + if(*f->value) str_copy(&config.ifcfg.manual->ip, f->value); + name2inet(&config.net.hostname, f->value); net_check_address(&config.net.hostname, 0); if(config.net.hostname.ipv4 && config.net.hostname.net.s_addr) { @@ -676,21 +679,33 @@ break; case key_netmask: + i = netmask_to_prefix(f->value); + if(i > 0) config.ifcfg.manual->netmask_prefix = i; + name2inet(&config.net.netmask, f->value); net_check_address(&config.net.netmask, 0); break; case key_gateway: + if(*f->value) str_copy(&config.ifcfg.manual->gw, f->value); + name2inet(&config.net.gateway, f->value); net_check_address(&config.net.gateway, 0); break; case key_ptphost: + if(*f->value) { + config.ifcfg.manual->ptp = 1; + str_copy(&config.ifcfg.manual->gw, f->value); + } + name2inet(&config.net.ptphost, f->value); net_check_address(&config.net.ptphost, 0); break; case key_nameserver: + if(*f->value) str_copy(&config.ifcfg.manual->ns, f->value); + for(config.net.nameservers = 0, sl = sl0 = slist_split(',', f->value); sl; sl = sl->next) { name2inet(&config.net.nameserver[config.net.nameservers], sl->key); net_check_address(&config.net.nameserver[config.net.nameservers], 0); @@ -798,6 +813,8 @@ break; case key_domain: + if(*f->value) str_copy(&config.ifcfg.manual->domain, f->value); + str_copy(&config.net.domain, f->value); break; @@ -1485,6 +1502,8 @@ break; case key_netdevice: + str_copy(&config.ifcfg.manual->device, *f->value ? f->value : NULL); + str_copy(&config.netdevice, short_dev(*f->value ? f->value : NULL)); break; @@ -2599,7 +2618,7 @@ config.net.configured = nc_dhcp; } else { - if(net_activate_ns()) { + if(net_static()) { fprintf(stderr, "net activation failed\n"); return 0; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/linuxrc-5.0.1/global.h new/linuxrc-5.0.3/global.h --- old/linuxrc-5.0.1/global.h 2014-07-18 14:19:00.000000000 +0200 +++ new/linuxrc-5.0.3/global.h 2014-07-18 17:18:43.000000000 +0200 @@ -276,6 +276,8 @@ unsigned dhcp:1; // use dhcp unsigned used:1; // config has been used unsigned pattern:1; // 'device' is shell glob + unsigned ptp:1; // ptp config, gw is ptp peer + int netmask_prefix; // prefix given via netmask option and only used if an ip doen't have one char *vlan; // vlan id, if any char *ip; // list of ip addresses, space separated char *gw; // gateway @@ -639,6 +641,8 @@ struct { ifcfg_t *list; /* list of ifcfg entries */ + ifcfg_t *manual; /* ifcfg data for manual network setup */ + ifcfg_t *all; /* all we ever did, kept for debugging */ slist_t *initial; /* list of initially set up network interfaces */ slist_t *if_state; /* config state of network interfaces */ slist_t *if_up; /* network interfaces != lo that are 'up' */ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/linuxrc-5.0.1/linuxrc.c new/linuxrc-5.0.3/linuxrc.c --- old/linuxrc-5.0.1/linuxrc.c 2014-07-18 13:24:59.000000000 +0200 +++ new/linuxrc-5.0.3/linuxrc.c 2014-07-18 16:37:38.000000000 +0200 @@ -801,6 +801,8 @@ config.plymouth = 1; + config.ifcfg.manual = calloc(1, sizeof *config.ifcfg.manual); + #if defined(__s390__) || defined(__s390x__) config.linemode = 1; #endif diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/linuxrc-5.0.1/net.c new/linuxrc-5.0.3/net.c --- old/linuxrc-5.0.1/net.c 2014-07-18 15:17:19.000000000 +0200 +++ new/linuxrc-5.0.3/net.c 2014-07-23 11:14:46.000000000 +0200 @@ -49,12 +49,9 @@ #include "auto2.h" -static int net_activate4(void); -static int net_activate6(void); #if defined(__s390__) || defined(__s390x__) int net_activate_s390_devs_ex(hd_t* hd, char** device); #endif -static void net_setup_nameserver(void); static int net_choose_device(void); static int net_input_data(void); @@ -127,11 +124,6 @@ break; } str_copy(&ip.name, sl->key); -/* net_check_address(&ip, 0); - if(!ip.ok) { - dia_message("Each domain must be a valid IP address.", MSGTYPE_ERROR); - break; - } */ } if(!sl) { @@ -152,7 +144,7 @@ /* * Configure network. Ask for network config data if necessary. - * Does either DHCP, BOOTP or calls net_activate_ns() to setup the interface. + * Calls either net_dhcp() or net_static() to setup the interface. * * Return: * 0: ok @@ -172,7 +164,7 @@ if(!config.win && !config.manual) return 0; - // really here? + // FIXME: not really here net_ask_password(); if( @@ -216,16 +208,15 @@ } else { rc = net_input_data(); - if(!rc) config.net.configured = nc_static; + if(!rc) { + net_static(); + config.net.configured = nc_static; + } } if(rc) return -1; - if(net_activate_ns()) { - dia_message("An error occurred during the network configuration. Your network card probably was not recognized by the kernel.", MSGTYPE_ERROR); - config.net.configured = nc_none; - if(!config.test) return rc = -1; - } + // dia_message("An error occurred during the network configuration. Your network card probably was not recognized by the kernel.", MSGTYPE_ERROR); return rc; } @@ -285,9 +276,9 @@ * * config.net.device: interface */ -int net_activate_ns() +int net_static() { - int err4 = 1, err6 = 1; + // int err4 = 1, err6 = 1; char *s; /* make sure we get the interface name if a mac was passed */ @@ -296,326 +287,14 @@ config.net.device = s; } - if(config.net.ipv4) err4 = net_activate4(); - if(config.net.ipv6) err6 = net_activate6(); - - if(!err4 || !err6) { - net_setup_nameserver(); - if(!config.net.dhcp_active) ifcfg_write2(NULL, NULL, 0); - } - - // at least one should have worked - return err4 && err6 ? 1 : 0; -} - - -/* - * Setup IPv4 network interface. - * - * Return: - * 0: ok - * != 0: error code - * - * Global vars changed: - * config.net.is_configured - * - * Does nothing if DHCP is active. - * - * config.net.device: interface - */ -int net_activate4() -{ - int socket_ii; - struct ifreq interface_ri; - struct rtentry route_ri; - struct sockaddr_in sockaddr_ri; - int error_ii = FALSE; - char command[1000]; - int rc; - - if(!config.net.ifconfig || config.net.dhcp_active) return 0; + // net_setup_nameserver - if(config.test) { - config.net.is_configured = nc_static; + config.ifcfg.manual->dhcp = 0; + ifcfg_write2(config.net.device, config.ifcfg.manual, 0); - return 0; - } - - if(!config.net.device) { - util_error_trace("net_activate: no network interface!\n"); - return 1; - } - - config.net.is_configured = nc_none; - - net_apply_ethtool(config.net.device, config.net.hwaddr); - - check_ptp(); - - if( - !config.net.ptp && - !config.forceip && - util_check_exist("/sbin/arping") - ) { - sprintf(command, "ifconfig %s up", config.net.device); - util_error_trace("net_activate: %s\n", command); - rc = system(command); - if (rc) { - util_error_trace("net_activate: ifconfig %s up failed!\n", config.net.device); - return 1; - } - - sleep(config.net.ifup_wait + 2); - - sprintf(command, "arping -c 1 -I %s -D %s 1>&2", config.net.device, inet_ntoa(config.net.hostname.ip)); - util_error_trace("net_activate: %s\n", command); - rc = system(command); - - sprintf(command, "ifconfig %s down", config.net.device); - (void)system (command); - util_error_trace("net_activate: %s\n", command); - - if (rc) { - util_error_trace("net_activate: address %s in use by another machine!\n", inet_ntoa(config.net.hostname.ip)); - sprintf(command, "IP address %s is already in use by another machine!", inet_ntoa(config.net.hostname.ip)); - dia_message(command, MSGTYPE_ERROR); - return 1; - } - } - - socket_ii = socket (AF_INET, SOCK_DGRAM, 0); - if (socket_ii == -1) - { - util_error_trace("net_activate: socket(AF_INET, SOCK_DGRAM, 0) failed at %d\n",__LINE__); - return (socket_ii); - } - - memset (&interface_ri, 0, sizeof (struct ifreq)); - strncpy (interface_ri.ifr_name, config.net.device, sizeof interface_ri.ifr_name - 1); - interface_ri.ifr_name[sizeof interface_ri.ifr_name - 1] = 0; - - sockaddr_ri.sin_family = AF_INET; - sockaddr_ri.sin_port = 0; - sockaddr_ri.sin_addr = config.net.hostname.ip; - memcpy (&interface_ri.ifr_addr, &sockaddr_ri, sizeof (sockaddr_ri)); - if (ioctl (socket_ii, SIOCSIFADDR, &interface_ri) < 0) - { - error_ii = TRUE; - util_error_trace("net_activate: SIOCSIFADDR failed at %d\n",__LINE__); - } - - if (config.net.ptp) - { - sockaddr_ri.sin_addr = config.net.ptphost.ip; - memcpy (&interface_ri.ifr_dstaddr, &sockaddr_ri, sizeof (sockaddr_ri)); - if (ioctl (socket_ii, SIOCSIFDSTADDR, &interface_ri) < 0) - { - error_ii = TRUE; - util_error_trace("net_activate: SIOCSIFDSTADDR failed at %d\n",__LINE__); - } - } - else - { - sockaddr_ri.sin_addr = config.net.netmask.ip; - memcpy (&interface_ri.ifr_netmask, &sockaddr_ri, sizeof (sockaddr_ri)); - if (ioctl (socket_ii, SIOCSIFNETMASK, &interface_ri) < 0) - if (config.net.netmask.ip.s_addr) - { - error_ii = TRUE; - util_error_trace("net_activate: SIOCSIFNETMASK failed at %d\n",__LINE__); - } - - sockaddr_ri.sin_addr = config.net.broadcast.ip; - memcpy (&interface_ri.ifr_broadaddr, &sockaddr_ri, sizeof (sockaddr_ri)); - if (ioctl (socket_ii, SIOCSIFBRDADDR, &interface_ri) < 0) - if (config.net.broadcast.ip.s_addr != 0xffffffff) - { - error_ii = TRUE; - util_error_trace("net_activate: SIOCSIFBRDADDR failed at %d\n",__LINE__); - } - } - - if (ioctl (socket_ii, SIOCGIFFLAGS, &interface_ri) < 0) - { - error_ii = TRUE; - util_error_trace("net_activate: SIOCGIFFLAGS failed at %d\n",__LINE__); - } - - interface_ri.ifr_flags |= IFF_UP | IFF_RUNNING; - if (config.net.ptp) - interface_ri.ifr_flags |= IFF_POINTOPOINT | IFF_NOARP; - else - interface_ri.ifr_flags |= IFF_BROADCAST; - if (ioctl (socket_ii, SIOCSIFFLAGS, &interface_ri) < 0) - { - error_ii = TRUE; - util_error_trace("net_activate: SIOCSIFFLAGS failed at %d\n",__LINE__); - } - - memset (&route_ri, 0, sizeof (struct rtentry)); - route_ri.rt_dev = config.net.device; - - if (config.net.ptp) - { - sockaddr_ri.sin_addr = config.net.ptphost.ip; - memcpy (&route_ri.rt_dst, &sockaddr_ri, sizeof (sockaddr_ri)); - route_ri.rt_flags = RTF_UP | RTF_HOST; - if (ioctl (socket_ii, SIOCADDRT, &route_ri) < 0) - { - error_ii = TRUE; - util_error_trace("net_activate: SIOCADDRT failed at %d\n",__LINE__); - } - - memset (&route_ri.rt_dst, 0, sizeof (route_ri.rt_dst)); - route_ri.rt_dst.sa_family = AF_INET; - memcpy (&route_ri.rt_gateway, &sockaddr_ri, sizeof (sockaddr_ri)); - route_ri.rt_flags = RTF_UP | RTF_GATEWAY; - if (ioctl (socket_ii, SIOCADDRT, &route_ri) < 0) - { - error_ii = TRUE; - util_error_trace("net_activate: SIOCADDRT failed at %d\n",__LINE__); - } - } - else - { - sockaddr_ri.sin_addr = config.net.network.ip; - memcpy (&route_ri.rt_dst, &sockaddr_ri, sizeof (sockaddr_ri)); - route_ri.rt_flags = RTF_UP; - ioctl (socket_ii, SIOCADDRT, &route_ri); - - if ( - config.net.gateway.ip.s_addr && - config.net.gateway.ip.s_addr != config.net.hostname.ip.s_addr - ) - { - sockaddr_ri.sin_addr = config.net.gateway.ip; - memset (&route_ri.rt_dst, 0, sizeof (route_ri.rt_dst)); - route_ri.rt_dst.sa_family = AF_INET; - memcpy (&route_ri.rt_gateway, &sockaddr_ri, sizeof (sockaddr_ri)); - -/* route_ri.rt_flags = RTF_UP | RTF_HOST; - if (ioctl (socket_ii, SIOCADDRT, &route_ri) < 0) - { - error_ii = TRUE; - } */ - - route_ri.rt_flags = RTF_UP | RTF_GATEWAY; - if (ioctl (socket_ii, SIOCADDRT, &route_ri) < 0) - { - error_ii = TRUE; - util_error_trace("net_activate: SIOCADDRT failed at %d\n",__LINE__); - } - } - } - - close(socket_ii); - - if(!error_ii) { - config.net.is_configured = nc_static; - if(config.net.ifup_wait) sleep(config.net.ifup_wait); - } - - return error_ii; -} - - -/* - * Setup IPv6 network interface. - * - * Return: - * 0: ok - * != 0: error code - * - * Global vars changed: - * config.net.is_configured - * - * Does nothing if DHCP is active. - * - * config.net.device: interface - */ -int net_activate6() -{ - int err = 0, delay = config.net.ifup_wait + 5; - char *cmd = NULL, ip_buf[INET6_ADDRSTRLEN], buf1[512], buf2[512], c; - const char *ip; - FILE *f; - inet_t host6 = { }; - - if(!config.net.ifconfig || config.net.dhcp_active) return 0; - - if(config.test) { - config.net.is_configured = nc_static; - - return 0; - } - - if(!config.net.device) { - fprintf(stderr, "net_activate: no network interface!\n"); - return 1; - } - - config.net.is_configured = nc_none; - - if(!config.net.ipv4) net_apply_ethtool(config.net.device, config.net.hwaddr); - - strprintf(&cmd, "ip link set %s up", config.net.device); - err = system(cmd); - - if(!err) { - if( - config.net.hostname.ok && - config.net.hostname.ipv6 && - (ip = inet_ntop(AF_INET6, &config.net.hostname.ip6, ip_buf, sizeof ip_buf)) - ) { - strprintf(&cmd, "ip addr add %s/%u dev %s", ip, config.net.hostname.prefix6, config.net.device); - err = system(cmd); - } - else { - // wait for autoconfig - strprintf(&cmd, "ip -o addr show dev %s", config.net.device); - - do { - sleep(1); - - if((f = popen(cmd, "r"))) { - while(fgets(buf1, sizeof buf1, f)) { - if(sscanf(buf1, "%*d: %*s inet6 %511s scope global %c", buf2, &c) == 2) { - if(config.debug) fprintf(stderr, "ip6: %s\n", buf2); - name2inet(&host6, buf2); - net_check_address(&host6, 0); - if(host6.ok && host6.ipv6) { - config.net.hostname.ok = host6.ok; - config.net.hostname.ipv6 = host6.ipv6; - config.net.hostname.ip6 = host6.ip6; - config.net.hostname.prefix6 = host6.prefix6; - str_copy(&config.net.hostname.name, host6.name); - } - break; - } - } - pclose(f); - } - - } while(--delay > 0 && f && !config.net.hostname.ok && !config.net.hostname.ipv6); - } - - if( - config.net.gateway.ok && - config.net.gateway.ipv6 && - (ip = inet_ntop(AF_INET6, &config.net.gateway.ip6, ip_buf, sizeof ip_buf)) - ) { - strprintf(&cmd, "route -A inet6 add default gw %s", ip); - err = system(cmd); - if(config.debug) fprintf(stderr, "%s = %d\n", cmd, err); - } - } - - if(!err) { - config.net.is_configured = nc_static; - if(config.net.ifup_wait) sleep(config.net.ifup_wait); - } + net_wicked_up(config.net.device); - return err; + return 0; } @@ -1154,7 +833,7 @@ if(choice > 0) { str_copy(&config.net.device, item_devs[choice - 1]); - check_ptp(); + check_ptp(NULL); if(item_hds && item_hds[choice - 1]) { hd = item_hds[choice - 1]; @@ -1181,6 +860,7 @@ } +#if 0 /* * Let user enter nameservers. * @@ -1235,6 +915,7 @@ fclose(f); } } +#endif /* @@ -1585,7 +1266,6 @@ ifcfg = calloc(1, sizeof *ifcfg); ifcfg->dhcp = 1; - strprintf(&ifcfg->type, "dhcp%s", net_dhcp_type()); ifcfg_write2(config.net.device, ifcfg, 0); @@ -2461,7 +2141,7 @@ hd_t *net_list, *hd; hd_res_t *res; char *hwaddr; - ifcfg_t *ifcfg; + ifcfg_t *ifcfg, **ifcfg_p; if(!config.ifcfg.list) return; @@ -2500,7 +2180,9 @@ hd_free_hd_list(net_list); - // FIXME: free it + // append to config.ifcfg.all and clear list + for(ifcfg_p = &config.ifcfg.all; *ifcfg_p; ifcfg_p = &(*ifcfg_p)->next); + *ifcfg_p = config.ifcfg.list; config.ifcfg.list = NULL; } @@ -2508,7 +2190,7 @@ /* * Wrapper around ifcfg_write() that does some more logging. * - * If initial is set, mark interface as 'initial'; that is, no further auto + * If initial is set, mark interface is 'initial'; that is, no further auto * config is tried on it. */ int ifcfg_write2(char *device, ifcfg_t *ifcfg, int initial) @@ -2581,6 +2263,7 @@ slist_t *sl; slist_t *sl_ifcfg = NULL; slist_t *sl_ifroute = NULL; + unsigned ptp = 0; // use global values if(!device || !ifcfg) global_values = 1; @@ -2606,13 +2289,24 @@ if(!device) return 0; + ptp = check_ptp(device); + + if(ptp) fprintf(stderr, "check_ptp: ptp = %u\n", ptp); + + ptp |= ifcfg->ptp; + // 1. maybe dhcp config, but only if passed explicitly if(!global_values && ifcfg->dhcp) { is_dhcp = 1; sl = slist_append_str(&sl_ifcfg, "BOOTPROTO"); - str_copy(&sl->value, ifcfg->type); + if(ifcfg->type) { + str_copy(&sl->value, ifcfg->type); + } + else { + strprintf(&sl->value, "dhcp%s", net_dhcp_type()); + } if(ifcfg->vlan) { strprintf(&vlan, ".%s", ifcfg->vlan); sl = slist_append_str(&sl_ifcfg, "ETHERDEVICE"); @@ -2680,13 +2374,39 @@ if(!sl0->next) { sl = slist_append_str(&sl_ifcfg, "IPADDR"); str_copy(&sl->value, sl0->key); + if(ifcfg->netmask_prefix > 0 && !strchr(sl->value, '/')) { + strprintf(&sl->value, "%s/%d", sl->value, ifcfg->netmask_prefix); + } } else { for(i = 0, sl1 = sl0; sl1; sl1 = sl1->next) { sl = slist_append(&sl_ifcfg, slist_new()); strprintf(&sl->key, "IPADDR_%d", ++i); str_copy(&sl->value, sl1->key); + if(ifcfg->netmask_prefix > 0 && !strchr(sl->value, '/')) { + strprintf(&sl->value, "%s/%d", sl->value, ifcfg->netmask_prefix); + } + } + } + + sl0 = slist_free(sl0); + } + + if(ptp) { + if((sl0 = slist_split(' ', ifcfg->gw))) { + if(!sl0->next) { + sl = slist_append_str(&sl_ifcfg, "REMOTE_IPADDR"); + str_copy(&sl->value, sl0->key); + } + else { + for(i = 0, sl1 = sl0; sl1; sl1 = sl1->next) { + sl = slist_append(&sl_ifcfg, slist_new()); + strprintf(&sl->key, "REMOTE_IPADDR_%d", ++i); + str_copy(&sl->value, sl1->key); + } } + + sl0 = slist_free(sl0); } } @@ -2732,8 +2452,14 @@ } } else { - sl = slist_append(&sl_ifroute, slist_new()); - strprintf(&sl->key, "default %s - %s", gw, device); + slist_t *sl1, *sl0 = slist_split(' ', ifcfg->gw); + + for(sl1 = sl0; sl1; sl1 = sl1->next) { + sl = slist_append(&sl_ifroute, slist_new()); + strprintf(&sl->key, "default %s - %s", sl1->key, device); + } + + slist_free(sl0); } } } @@ -2904,19 +2630,7 @@ } } - if(config.debug) { - fprintf(stderr, " device = %s\n", ifcfg->device); - if(ifcfg->vlan) fprintf(stderr, " vlan = %s\n", ifcfg->vlan); - if(ifcfg->type) fprintf(stderr, " type = %s\n", ifcfg->type); - fprintf(stderr, " dhcp = %u, pattern = %u, used = %u\n", ifcfg->dhcp, ifcfg->pattern, ifcfg->used); - if(ifcfg->ip) fprintf(stderr, " ip = %s\n", ifcfg->ip); - if(ifcfg->gw) fprintf(stderr, " gw = %s\n", ifcfg->gw); - if(ifcfg->ns) fprintf(stderr, " ns = %s\n", ifcfg->ns); - if(ifcfg->domain) fprintf(stderr, " domain = %s\n", ifcfg->domain); - for (sl = ifcfg->flags; sl; sl = sl->next) { - fprintf(stderr, " %s = \"%s\"\n", sl->key, sl->value); - } - } + if(config.debug) fprintf(stderr, "%s", ifcfg_print(ifcfg)); return ifcfg; } @@ -2930,6 +2644,37 @@ /* + * Returns static buffer. + */ +char *ifcfg_print(ifcfg_t *ifcfg) +{ + slist_t *sl; + static char *buf = NULL; + + str_copy(&buf, NULL); + + strprintf(&buf, " device = %s\n", ifcfg->device); + if(ifcfg->vlan) strprintf(&buf, "%s vlan = %s\n", buf, ifcfg->vlan); + if(ifcfg->type) strprintf(&buf, "%s type = %s\n", buf, ifcfg->type); + strprintf(&buf, + "%s dhcp = %u, pattern = %u, used = %u, prefix = %d, ptp = %u\n", + buf, + ifcfg->dhcp, ifcfg->pattern, ifcfg->used, + ifcfg->netmask_prefix, ifcfg->ptp + ); + if(ifcfg->ip) strprintf(&buf, "%s ip = %s\n", buf, ifcfg->ip); + if(ifcfg->gw) strprintf(&buf, "%s gw = %s\n", buf, ifcfg->gw); + if(ifcfg->ns) strprintf(&buf, "%s ns = %s\n", buf, ifcfg->ns); + if(ifcfg->domain) strprintf(&buf, "%s domain = %s\n", buf, ifcfg->domain); + for (sl = ifcfg->flags; sl; sl = sl->next) { + strprintf(&buf, "%s %s = \"%s\"\n", buf, sl->key, sl->value); + } + + return buf; +} + + +/* * Run wicked to collect all interface states. * * config.ifcfg.if_state @@ -3083,3 +2828,26 @@ return config.ifcfg.if_up ? 0 : 1; } + +/* + * Check if interface is a ptp interface and set config.net.ptp accordingly. + */ +unsigned check_ptp(char *ifname) +{ + unsigned ptp = 0; + + if(!ifname) ifname = config.net.device; + + if( + ifname && + ( + !strncmp(ifname, "plip", sizeof "plip" - 1) || + !strncmp(ifname, "iucv", sizeof "iucv" - 1) || + !strncmp(ifname, "ctc", sizeof "ctc" - 1) || + !strncmp(ifname, "sl", sizeof "sl" - 1) + ) + ) ptp = 1; + + return config.net.ptp = ptp; +} + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/linuxrc-5.0.1/net.h new/linuxrc-5.0.3/net.h --- old/linuxrc-5.0.1/net.h 2014-07-18 14:51:03.000000000 +0200 +++ new/linuxrc-5.0.3/net.h 2014-07-21 13:18:44.000000000 +0200 @@ -13,7 +13,7 @@ int net_mount_cifs(char *mountpoint, inet_t *server, char *hostdir, char *user, char *password, char *workgroup, char *options); void net_stop(void); int net_check_address(inet_t *inet, int do_dns); -int net_activate_ns(void); +int net_static(void); int net_activate_s390_devs(void); int net_dhcp(void); unsigned net_config_mask(void); @@ -26,8 +26,10 @@ void net_update_ifcfg(void); ifcfg_t *ifcfg_parse(char *str); ifcfg_t *ifcfg_append(ifcfg_t **p0, ifcfg_t *p); +char *ifcfg_print(ifcfg_t *ifcfg); void net_update_state(void); void net_wicked_up(char *ifname); void net_wicked_down(char *ifname); int netmask_to_prefix(char *netmask); int net_config_needed(int really); +unsigned check_ptp(char *ifname); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/linuxrc-5.0.1/url.c new/linuxrc-5.0.3/url.c --- old/linuxrc-5.0.1/url.c 2014-07-18 14:03:11.000000000 +0200 +++ new/linuxrc-5.0.3/url.c 2014-07-23 10:56:16.000000000 +0200 @@ -2317,7 +2317,7 @@ if(config.net.configured == nc_none) config.net.configured = nc_static; - check_ptp(); + check_ptp(NULL); /* we need at least ip & netmask for static network config */ /* just netmask for PTP devices */ @@ -2332,7 +2332,7 @@ config.net.configured = nc_dhcp; } - if(net_activate_ns()) { + if(config.net.configured != nc_dhcp && net_static()) { fprintf(stderr, "network setup failed\n"); config.net.configured = nc_none; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/linuxrc-5.0.1/util.c new/linuxrc-5.0.3/util.c --- old/linuxrc-5.0.1/util.c 2014-07-18 15:09:02.000000000 +0200 +++ new/linuxrc-5.0.3/util.c 2014-07-21 13:18:13.000000000 +0200 @@ -1270,6 +1270,38 @@ } } + if(config.ifcfg.all) { + ifcfg_t *ifcfg; + slist_t *sl_ifcfg; + strcpy(buf, "ifcfg entries:"); + slist_append_str(&sl0, buf); + for(ifcfg = config.ifcfg.all; ifcfg; ifcfg = ifcfg->next) { + sl_ifcfg = slist_split('\n', ifcfg_print(ifcfg)); + for(sl = sl_ifcfg; sl; sl = sl->next) { + if(*sl->key || ifcfg->next) { // keep newline between entries + sprintf(buf, "%s", sl->key); + slist_append_str(&sl0, buf); + } + } + slist_free(sl_ifcfg); + } + } + + if(config.ifcfg.manual) { + ifcfg_t *ifcfg = config.ifcfg.manual; + slist_t *sl_ifcfg; + strcpy(buf, "manual ifcfg entry:"); + slist_append_str(&sl0, buf); + sl_ifcfg = slist_split('\n', ifcfg_print(ifcfg)); + for(sl = sl_ifcfg; sl; sl = sl->next) { + if(*sl->key) { + sprintf(buf, "%s", sl->key); + slist_append_str(&sl0, buf); + } + } + slist_free(sl_ifcfg); + } + if(config.cdid) { sprintf(buf, "cdrom id = %s", config.cdid); slist_append_str(&sl0, buf); @@ -2249,7 +2281,7 @@ text = strdup(text); - if(isspace(del)) { + if(isblank(del)) { len = strlen(text); for(i = 0; i < len; i++) if(isspace(text[i])) text[i] = 0; @@ -4769,24 +4801,6 @@ } -/* - * Check if interface is a ptp interface and set config.net.ptp accordingly. - */ -void check_ptp() -{ - config.net.ptp = 0; - - if(!config.net.device) return; - - if( - !strncmp(config.net.device, "plip", sizeof "plip" - 1) || - !strncmp(config.net.device, "iucv", sizeof "iucv" - 1) || - !strncmp(config.net.device, "ctc", sizeof "ctc" - 1) || - !strncmp(config.net.device, "sl", sizeof "sl" - 1) - ) config.net.ptp = 1; -} - - /* * buf: at least 6 bytes */ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/linuxrc-5.0.1/util.h new/linuxrc-5.0.3/util.h --- old/linuxrc-5.0.1/util.h 2014-06-27 11:32:38.000000000 +0200 +++ new/linuxrc-5.0.3/util.h 2014-07-21 13:18:27.000000000 +0200 @@ -154,8 +154,6 @@ void util_restart(); -void check_ptp(void); - char *compress_type(void *buf); char *compressed_file(char *name); char *compressed_archive(char *name, char **archive); -- To unsubscribe, e-mail: opensuse-commit+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-commit+help@opensuse.org
participants (1)
-
root@hilbert.suse.de