Hello community, here is the log from the commit of package linuxrc for openSUSE:Factory checked in at 2014-11-28 08:47:00 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 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-10-14 07:10:20.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.linuxrc.new/linuxrc.changes 2014-11-28 08:47:02.000000000 +0100 @@ -1,0 +2,6 @@ +Wed Nov 26 13:10:50 CET 2014 - snwint_jenk...@suse.com + +- set explicit route to gateway (if outside subnet) (bnc #906771) +- 5.0.28 + +------------------------------------------------------------------- Old: ---- linuxrc-5.0.27.tar.xz New: ---- linuxrc-5.0.28.tar.xz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ linuxrc.spec ++++++ --- /var/tmp/diff_new_pack.pUEdhj/_old 2014-11-28 08:47:04.000000000 +0100 +++ /var/tmp/diff_new_pack.pUEdhj/_new 2014-11-28 08:47:04.000000000 +0100 @@ -25,7 +25,7 @@ Summary: SUSE Installation Program License: GPL-3.0+ Group: System/Boot -Version: 5.0.27 +Version: 5.0.28 Release: 0 Source: %{name}-%{version}.tar.xz BuildRoot: %{_tmppath}/%{name}-%{version}-build ++++++ linuxrc-5.0.27.tar.xz -> linuxrc-5.0.28.tar.xz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/linuxrc-5.0.27/VERSION new/linuxrc-5.0.28/VERSION --- old/linuxrc-5.0.27/VERSION 2014-10-13 13:34:49.000000000 +0200 +++ new/linuxrc-5.0.28/VERSION 2014-11-26 13:10:00.000000000 +0100 @@ -1 +1 @@ -5.0.27 +5.0.28 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/linuxrc-5.0.27/changelog new/linuxrc-5.0.28/changelog --- old/linuxrc-5.0.27/changelog 2014-10-13 13:34:49.000000000 +0200 +++ new/linuxrc-5.0.28/changelog 2014-11-26 13:10:00.000000000 +0100 @@ -1,3 +1,6 @@ +2014-11-26: 5.0.28 + - set explicit route to gateway (if outside subnet) (bnc #906771) + 2014-10-13: 5.0.27 - update git2log script diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/linuxrc-5.0.27/net.c new/linuxrc-5.0.28/net.c --- old/linuxrc-5.0.27/net.c 2014-10-13 13:34:49.000000000 +0200 +++ new/linuxrc-5.0.28/net.c 2014-11-26 13:10:00.000000000 +0100 @@ -69,6 +69,7 @@ static char *inet2str(inet_t *inet, int type); static int net_get_ip(char *text, char **ip, int with_prefix); static int net_check_ip(char *buf, int multi, int with_prefix); +static int compare_subnet(char *ip1, char *ip2, unsigned prefix); /* @@ -2150,6 +2151,8 @@ slist_t *sl_ifroute = NULL; slist_t *sl_global = NULL; unsigned ptp = 0; + char *v4_ip = NULL; // allocated + unsigned v4_prefix = 0; // obsolete: use global values if(!device || !ifcfg) { @@ -2225,6 +2228,15 @@ if(ifcfg->netmask_prefix > 0 && !strchr(sl->value, '/')) { strprintf(&sl->value, "%s/%d", sl->value, ifcfg->netmask_prefix); } + + // remember ip and net prefix for later use + str_copy(&v4_ip, sl0->key); + v4_prefix = ifcfg->netmask_prefix; + char *t = strchr(v4_ip, '/'); + if(t) { + *t = 0; + v4_prefix = atoi(t + 1); + } } else { for(i = 0, sl1 = sl0; sl1; sl1 = sl1->next) { @@ -2315,6 +2327,14 @@ for(sl1 = sl0; sl1; sl1 = sl1->next) { sl = slist_append(&sl_ifroute, slist_new()); + + // set explicit route to gw unless gw is in the same ipv4 subnet + // note: we might as well set it always + if(!compare_subnet(v4_ip, sl1->key, v4_prefix)) { + strprintf(&sl->key, "%s - - %s", sl1->key, device); + sl = slist_append(&sl_ifroute, slist_new()); + } + strprintf(&sl->key, "default %s - %s", sl1->key, device); } @@ -2403,6 +2423,7 @@ str_copy(&ns, NULL); str_copy(&domain, NULL); str_copy(&vlan, NULL); + str_copy(&v4_ip, NULL); slist_free(sl_global); slist_free(sl_ifcfg); @@ -2887,3 +2908,30 @@ } } + +/* + * Check whether ip1 and ip2 share the same ipv4 subnet. + */ +int compare_subnet(char *ip1, char *ip2, unsigned prefix) +{ + struct in_addr ip4_1, ip4_2; + uint32_t mask; + int ok = 0; + + if(prefix > 32 || !ip1 || !ip2) return 0; + + // no ipv6 + if(strchr(ip1, ':') || strchr(ip2, ':')) return 0; + + mask = htonl(prefix ? -1 << (32 - prefix) : 0); + + if( + inet_pton(AF_INET, ip1, &ip4_1) > 0 && + inet_pton(AF_INET, ip2, &ip4_2) > 0 + ) { + ok = (ip4_1.s_addr & mask) == (ip4_2.s_addr & mask); + } + + return ok; +} + -- To unsubscribe, e-mail: opensuse-commit+unsubscr...@opensuse.org For additional commands, e-mail: opensuse-commit+h...@opensuse.org