Accepting request 58010 from security:netfilter

Accepted submit request 58010 from user jengelh

OBS-URL: https://build.opensuse.org/request/show/58010
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/iproute2?expand=0&rev=38
This commit is contained in:
Marcus Rückert 2011-01-14 00:41:58 +00:00 committed by Git OBS Bridge
commit c2898edaac
6 changed files with 238 additions and 16 deletions

View File

@ -16,7 +16,7 @@ Index: ip/ip6tunnel.c
===================================================================
--- ip/ip6tunnel.c.orig
+++ ip/ip6tunnel.c
@@ -261,8 +261,9 @@ static int do_tunnels_list(struct ip6_tn
@@ -262,8 +262,9 @@ static int do_tunnels_list(struct ip6_tn
}
/* skip two lines at the begenning of the file */
@ -70,7 +70,7 @@ Index: ip/iptunnel.c
===================================================================
--- ip/iptunnel.c.orig
+++ ip/iptunnel.c
@@ -412,8 +412,9 @@ static int do_tunnels_list(struct ip_tun
@@ -407,8 +407,9 @@ static int do_tunnels_list(struct ip_tun
return -1;
}
@ -81,7 +81,7 @@ Index: ip/iptunnel.c
+ res = fgets(buf, sizeof(buf), fp);
while (fgets(buf, sizeof(buf), fp) != NULL) {
char *ptr;
int index, type;
Index: ip/rtmon.c
===================================================================
--- ip/rtmon.c.orig
@ -117,7 +117,7 @@ Index: misc/ifstat.c
===================================================================
--- misc/ifstat.c.orig
+++ misc/ifstat.c
@@ -717,8 +717,9 @@ int main(int argc, char *argv[])
@@ -716,8 +716,9 @@ int main(int argc, char *argv[])
fclose(tfp);
}
if (uptime >= 0 && time(NULL) >= stb.st_mtime+uptime) {
@ -128,7 +128,7 @@ Index: misc/ifstat.c
}
}
@@ -760,7 +761,8 @@ int main(int argc, char *argv[])
@@ -759,7 +760,8 @@ int main(int argc, char *argv[])
dump_incr_db(stdout);
}
if (!no_update) {

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:06d028c301203b39e82b7c1923fffc0169231951080238a91e13a0c2739512cf
size 387857

View File

@ -0,0 +1,197 @@
From ff2e5a2ada6196ce4ed89a76b5e86f047c9a63f4 Mon Sep 17 00:00:00 2001
From: Marius Tomaschewski <mt@suse.de>
Date: Wed, 12 Jan 2011 16:41:45 +0100
Subject: [PATCH] ip route rtt metrics time unit is milliseconds
Adopted ip route rtt,rttvar,rto_min metrics time unit to milliseconds
instead of jiffies as required by recent kernels (>=2.6.27).
Added an get_rtt_metrics_units function providing the unit and the
get_time_in_units as successor of get_jiffies function, allowing to
specify the unit. The get_rtt_metrics_units can be extended to detect
and handle also older kernels.
This fixes also the inconsistent use of get_user_hz in print_route
and get_hz in get_jiffies function that return different units.
---
include/utils.h | 1 +
ip/iproute.c | 38 ++++++++++++++++++++++++++------------
lib/utils.c | 24 +++++++++++++-----------
3 files changed, 40 insertions(+), 23 deletions(-)
diff --git a/include/utils.h b/include/utils.h
index 3da6998..3d98c01 100644
--- a/include/utils.h
+++ b/include/utils.h
@@ -80,6 +80,7 @@ extern int mask2bits(__u32 netmask);
extern int get_integer(int *val, const char *arg, int base);
extern int get_unsigned(unsigned *val, const char *arg, int base);
extern int get_jiffies(unsigned *val, const char *arg, int base, int *raw);
+extern int get_time_in_units(unsigned *val, const char *arg, int base, int *raw, unsigned unit);
#define get_byte get_u8
#define get_ushort get_u16
#define get_short get_s16
diff --git a/ip/iproute.c b/ip/iproute.c
index 0d69290..830b0a3 100644
--- a/ip/iproute.c
+++ b/ip/iproute.c
@@ -33,6 +33,21 @@
#define RTAX_RTTVAR RTAX_HOPS
#endif
+#define TIME_UNIT_MS 1000
+
+static unsigned get_rtt_metrics_units(void)
+{
+ /*
+ * recent kernels (>=2.6.27) are using milliseconds base.
+ * Note: To support older kernels, return the proper HZ...
+ *
+ * final unit for rto_min: unit
+ * rttvar: unit * 4
+ * rtt: unit * 8
+ */
+ return TIME_UNIT_MS;
+}
+
enum list_action {
IPROUTE_LIST,
IPROUTE_FLUSH,
@@ -522,12 +537,11 @@ int print_route(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
mxlock = *(unsigned*)RTA_DATA(mxrta[RTAX_LOCK]);
for (i=2; i<= RTAX_MAX; i++) {
- unsigned val;
+ unsigned long long val; /* val *= 1000 below */
+ unsigned unit = get_rtt_metrics_units();
if (mxrta[i] == NULL)
continue;
- if (!hz)
- hz = get_user_hz();
if (i < sizeof(mx_names)/sizeof(char*) && mx_names[i])
fprintf(fp, " %s", mx_names[i]);
@@ -543,24 +557,24 @@ int print_route(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
val = 0;
/* fall through */
default:
- fprintf(fp, " %u", val);
+ fprintf(fp, " %llu", val);
break;
case RTAX_RTT:
case RTAX_RTTVAR:
case RTAX_RTO_MIN:
- val *= 1000;
+ val *= TIME_UNIT_MS;
if (i == RTAX_RTT)
val /= 8;
else if (i == RTAX_RTTVAR)
val /= 4;
- if (val >= hz)
+ if (val >= unit)
fprintf(fp, " %llums",
- (unsigned long long) val / hz);
+ val / unit);
else
- fprintf(fp, " %.2fms",
- (double)val / hz);
+ fprintf(fp, " %.8fms",
+ (double)val / unit);
}
}
}
@@ -840,7 +854,7 @@ int iproute_modify(int cmd, unsigned flags, int argc, char **argv)
mxlock |= (1<<RTAX_RTT);
NEXT_ARG();
}
- if (get_jiffies(&rtt, *argv, 0, &raw))
+ if (get_time_in_units(&rtt, *argv, 0, &raw, get_rtt_metrics_units()))
invarg("\"rtt\" value is invalid\n", *argv);
rta_addattr32(mxrta, sizeof(mxbuf), RTAX_RTT,
(raw) ? rtt : rtt * 8);
@@ -848,7 +862,7 @@ int iproute_modify(int cmd, unsigned flags, int argc, char **argv)
unsigned rto_min;
NEXT_ARG();
mxlock |= (1<<RTAX_RTO_MIN);
- if (get_jiffies(&rto_min, *argv, 0, &raw))
+ if (get_time_in_units(&rto_min, *argv, 0, &raw, get_rtt_metrics_units()))
invarg("\"rto_min\" value is invalid\n",
*argv);
rta_addattr32(mxrta, sizeof(mxbuf), RTAX_RTO_MIN,
@@ -900,7 +914,7 @@ int iproute_modify(int cmd, unsigned flags, int argc, char **argv)
mxlock |= (1<<RTAX_RTTVAR);
NEXT_ARG();
}
- if (get_jiffies(&win, *argv, 0, &raw))
+ if (get_time_in_units(&win, *argv, 0, &raw, get_rtt_metrics_units()))
invarg("\"rttvar\" value is invalid\n", *argv);
rta_addattr32(mxrta, sizeof(mxbuf), RTAX_RTTVAR,
(raw) ? win : win * 4);
diff --git a/lib/utils.c b/lib/utils.c
index a60d884..a21a2ae 100644
--- a/lib/utils.c
+++ b/lib/utils.c
@@ -102,6 +102,11 @@ int get_unsigned(unsigned *val, const char *arg, int base)
int get_jiffies(unsigned *jiffies, const char *arg, int base, int *raw)
{
+ return get_time_in_units(jiffies, arg, base, raw, get_hz());
+}
+
+int get_time_in_units(unsigned *val, const char *arg, int base, int *raw, unsigned unit)
+{
double t;
unsigned long res;
char *p;
@@ -120,37 +125,34 @@ int get_jiffies(unsigned *jiffies, const char *arg, int base, int *raw)
if (p == arg)
return -1;
- if (__iproute2_hz_internal == 0)
- __iproute2_hz_internal = __get_hz();
-
*raw = 1;
if (*p) {
*raw = 0;
if (strcasecmp(p, "s") == 0 || strcasecmp(p, "sec")==0 ||
strcasecmp(p, "secs")==0)
- t *= __iproute2_hz_internal;
+ t *= unit;
else if (strcasecmp(p, "ms") == 0 || strcasecmp(p, "msec")==0 ||
strcasecmp(p, "msecs") == 0)
- t *= __iproute2_hz_internal/1000.0;
+ t *= unit/1000.0;
else if (strcasecmp(p, "us") == 0 || strcasecmp(p, "usec")==0 ||
strcasecmp(p, "usecs") == 0)
- t *= __iproute2_hz_internal/1000000.0;
+ t *= unit/1000000.0;
else if (strcasecmp(p, "ns") == 0 || strcasecmp(p, "nsec")==0 ||
strcasecmp(p, "nsecs") == 0)
- t *= __iproute2_hz_internal/1000000000.0;
+ t *= unit/1000000000.0;
else if (strcasecmp(p, "j") == 0 || strcasecmp(p, "hz") == 0 ||
strcasecmp(p,"jiffies") == 0)
- t *= 1.0; /* allow suffix, do nothing */
+ t *= unit/(double)get_hz();
else
return -1;
}
/* emulate ceil() without having to bring-in -lm and always be >= 1 */
- *jiffies = t;
- if (*jiffies < t)
- *jiffies += 1;
+ *val = t;
+ if (*val < t)
+ *val += 1;
return 0;
--
1.7.1

3
iproute2-2.6.37.tar.bz2 Normal file
View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:71754f8ad68facdb97d0cb9d7a298dc7f1ba069370bce902b661e06959f264e3
size 388866

View File

@ -1,3 +1,23 @@
-------------------------------------------------------------------
Wed Jan 12 16:02:26 UTC 2011 - mt@suse.de
- Adopted ip route rtt,rttvar,rto_min metrics time unit to
milliseconds as required by recent kernels (bnc#659746).
-------------------------------------------------------------------
Tue Jan 11 00:45:02 UTC 2011 - jengelh@medozas.de
- Update to iproute2-2.6.37
* Support for iptables >= 1.4.9
* Support for GRE in XFRM
* tc f_flow now knows rxhash
* Support for macvtap "mode" parameter
* tc ACT_CSUM support
* added `ip route save` and `ip route restore` commands
- Spec file updates
* Remove pointless AutoReqProv:on (that's the default)
* Enable tc's m_xt
-------------------------------------------------------------------
Fri Dec 3 10:29:55 CET 2010 - ms@suse.de

View File

@ -1,5 +1,5 @@
#
# spec file for package iproute2 (Version 2.6.35+9)
# spec file for package iproute2 (Version 2.6.37)
#
# Copyright (c) 2010 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
@ -20,13 +20,13 @@
Name: iproute2
BuildRequires: bison db-devel flex ghostscript-fonts-std ghostscript-x11 libpng-devel libtiff-devel sgmltool texlive-latex xorg-x11-devel
BuildRequires: iptables-devel
License: GPLv2+
Group: Productivity/Networking/Routing
Provides: iproute
AutoReqProv: on
Version: 2.6.35+9
Release: 3
%define rversion 2.6.35+9
Provides: iproute
Version: 2.6.37
Release: 1
%define rversion 2.6.37
Summary: Advanced Routing
Url: http://developer.osdl.org/dev/iproute2/
Source0: %name-%rversion.tar.bz2
@ -39,6 +39,7 @@ Patch8: %name-2.6.29-1-skbedit-memset.diff
Patch9: %name-2.6.29-1-iptunnel-fclose.diff
Patch10: %name-2.6.29-1-ss-pclose.diff
Patch13: %name-2.6.29-1-memleak.diff
Patch14: %name-2.6.37-rtt-metrics-units.diff
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%description
@ -84,19 +85,22 @@ as well as examples and other outdated files.
%patch9
%patch10
%patch13
%patch14 -p1
find . -name *.orig -print0 | xargs -r0 rm -v
%build
# build with -fPIC. For details see
# https://bugzilla.novell.com/show_bug.cgi?id=388021
make %{?_smp_mflags} LIBDIR=/usr/share CCOPTS="-D_GNU_SOURCE $RPM_OPT_FLAGS -Wstrict-prototypes -fPIC"
make %{?_smp_mflags} LIBDIR=%_libdir CCOPTS="-D_GNU_SOURCE $RPM_OPT_FLAGS -Wstrict-prototypes -fPIC"
cd doc
make pdf
%install
install -d $RPM_BUILD_ROOT/{etc/,sbin/,usr/{sbin,share/man/man{3,8}}}
install -d $RPM_BUILD_ROOT/{/usr/include,%_libdir,/usr/share}
make install DESTDIR=$RPM_BUILD_ROOT LIBDIR=/usr/share
make install DESTDIR=$RPM_BUILD_ROOT LIBDIR=%_libdir \
MODDESTDIR="$RPM_BUILD_ROOT/%_libdir"
rm -f "$RPM_BUILD_ROOT/%_libdir/m_ipt.so"
install lib/libnetlink.a $RPM_BUILD_ROOT/%_libdir
install include/libnetlink.h $RPM_BUILD_ROOT/usr/include
mv $RPM_BUILD_ROOT/usr/sbin/ip $RPM_BUILD_ROOT/sbin
@ -121,6 +125,7 @@ rm -rf $RPM_BUILD_ROOT
%config(noreplace) /etc/iproute2/rt_realms
%config(noreplace) /etc/iproute2/rt_tables
%config(noreplace) /etc/iproute2/ematch_map
%_libdir/m_xt.so
%dir /usr/share/tc
%attr(644,root,root)/usr/share/tc/*