diff --git a/README.md b/README.md index 999474d..42233a8 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,4 @@ # iproute +Iproute2 is a collection of utilities for controlling TCP / IP networking and Traffic Control in Linux. + diff --git a/iproute-2.6.16-ip_resolve_crash.patch b/iproute-2.6.16-ip_resolve_crash.patch new file mode 100644 index 0000000..2dbe609 --- /dev/null +++ b/iproute-2.6.16-ip_resolve_crash.patch @@ -0,0 +1,11 @@ +--- iproute2-2.6.16-060323/lib/utils.c.crash 2005-09-01 21:21:50.000000000 +0200 ++++ iproute2-2.6.16-060323/lib/utils.c 2006-09-19 13:47:26.000000000 +0200 +@@ -439,7 +439,7 @@ + len = 4; + } + +- hash = addr[len-1] ^ addr[len-2] ^ addr[len-3] ^ addr[len-4]; ++ hash = (addr[len-1] ^ addr[len-2] ^ addr[len-3] ^ addr[len-4]) & 0xff; + + for (n = nht[hash]; n; n = n->next) { + if (n->addr.family == af && diff --git a/iproute-2.6.20-makefile.patch b/iproute-2.6.20-makefile.patch new file mode 100644 index 0000000..724d971 --- /dev/null +++ b/iproute-2.6.20-makefile.patch @@ -0,0 +1,19 @@ +--- iproute-2.6.20-070313/Makefile.orig 2007-03-30 18:27:27.000000000 +0200 ++++ iproute-2.6.20-070313/Makefile 2007-03-30 18:28:40.000000000 +0200 +@@ -3,6 +3,7 @@ + CONFDIR=/etc/iproute2 + DOCDIR=/usr/share/doc/iproute2 + MANDIR=/usr/share/man ++KERNEL_INCLUDE=/usr/include + + # Path to db_185.h include + DBM_INCLUDE:=/usr/include +@@ -21,7 +22,7 @@ + + CC = gcc + HOSTCC = gcc +-CCOPTS = -D_GNU_SOURCE -O2 -Wstrict-prototypes -Wall ++CCOPTS = -D_GNU_SOURCE -O2 -Wstrict-prototypes -Wall $(RPM_OPT_FLAGS) + CFLAGS = $(CCOPTS) -I../include $(DEFINES) + YACCFLAGS = -d -t -v + diff --git a/iproute-2.6.20-tc_pfifo_man.patch b/iproute-2.6.20-tc_pfifo_man.patch new file mode 100644 index 0000000..a4e7510 --- /dev/null +++ b/iproute-2.6.20-tc_pfifo_man.patch @@ -0,0 +1,23 @@ +--- iproute2-2.6.16-060323/man/man8/ip.8.old 2006-01-03 20:25:29.000000000 +0100 ++++ iproute2-2.6.16-060323/man/man8/ip.8 2006-10-02 15:13:05.000000000 +0200 +@@ -176,6 +176,8 @@ replace " | " monitor " } " + .IR NUMBER " ] [ " + .B cwnd + .IR NUMBER " ] [ " ++.B initcwnd ++.IR NUMBER " ] [ " + .B ssthresh + .IR REALM " ] [ " + .B realms +@@ -1080,6 +1079,11 @@ the clamp for congestion window. It is + flag is not used. + + .TP ++.BI initcwnd " NUMBER " ++The maximum initial congestion window (cwnd) size in MSS of a ++TCP connection. ++ ++.TP + .BI advmss " NUMBER " "(2.3.15+ only)" + the MSS ('Maximal Segment Size') to advertise to these + destinations when establishing TCP connections. If it is not given, diff --git a/iproute-2.6.29-cross_fix.patch b/iproute-2.6.29-cross_fix.patch new file mode 100644 index 0000000..f2565f7 --- /dev/null +++ b/iproute-2.6.29-cross_fix.patch @@ -0,0 +1,11 @@ +--- ./misc/arpd.c 2008-10-08 14:21:56.000000000 +0000 ++++ ./misc/arpd.c~ 2008-10-08 14:21:07.000000000 +0000 +@@ -206,7 +206,7 @@ + if (getsockname(udp_sock, (struct sockaddr*)&dst, &len) < 0) + return -1; + +- ah->ar_hrd = htons(ifr.ifr_hwaddr.sa_family); ++ ah->ar_hrd = htons(ARPHRD_ETHER); + ah->ar_pro = htons(ETH_P_IP); + ah->ar_hln = 6; + ah->ar_pln = 4; diff --git a/iproute-2.6.29-if_tunnel.patch b/iproute-2.6.29-if_tunnel.patch new file mode 100644 index 0000000..afdec1b --- /dev/null +++ b/iproute-2.6.29-if_tunnel.patch @@ -0,0 +1,11 @@ +diff -Nru iproute2-2.6.29.orig/include/linux/if_tunnel.h iproute2-2.6.29/include/linux/if_tunnel.h +--- iproute2-2.6.29.orig/include/linux/if_tunnel.h 2009-03-24 23:15:14.000000000 +0100 ++++ iproute2-2.6.29/include/linux/if_tunnel.h 2009-10-11 13:43:05.000000000 +0200 +@@ -3,6 +3,7 @@ + + #include + ++#include + + #define SIOCGETTUNNEL (SIOCDEVPRIVATE + 0) + #define SIOCADDTUNNEL (SIOCDEVPRIVATE + 1) diff --git a/iproute-3.8.0-gcc-4.8.patch b/iproute-3.8.0-gcc-4.8.patch new file mode 100644 index 0000000..aa04d83 --- /dev/null +++ b/iproute-3.8.0-gcc-4.8.patch @@ -0,0 +1,25 @@ +From 1f3ea01fe2ff61cbbca6474f7d9903a0756a4f44 Mon Sep 17 00:00:00 2001 +From: Kamil Rytarowski +Date: Fri, 3 May 2013 18:43:38 +0200 +Subject: [PATCH] Feed GCC 4.8.0 against new warning that is shipped with + -Wall: -Wsizeof-pointer-memaccess. + +--- + misc/lnstat.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/misc/lnstat.c b/misc/lnstat.c +index bd19cc1..90198b7 100644 +--- a/misc/lnstat.c ++++ b/misc/lnstat.c +@@ -166,7 +166,7 @@ static struct table_hdr *build_hdr_string(struct lnstat_file *lnstat_files, + + for (i = 0; i < HDR_LINES; i++) { + th.hdr[i] = malloc(HDR_LINE_LENGTH); +- memset(th.hdr[i], 0, sizeof(th.hdr[i])); ++ memset(th.hdr[i], 0, HDR_LINE_LENGTH); + } + + for (i = 0; i < fps->num; i++) { +-- +1.8.1.5 diff --git a/iproute.spec b/iproute.spec new file mode 100644 index 0000000..2c47309 --- /dev/null +++ b/iproute.spec @@ -0,0 +1,242 @@ +%define majver %(echo %version | cut -d. -f 1-3) +%define extraver -%(echo %version | cut -d. -f4) +%define pckdocdir %{_datadir}/doc/iproute-%{version} + +Name: iproute +Version: 3.12.0 +Release: 1mamba +Summary: Advanced routing tools including ipv6 routing +Group: Network/Routing +Vendor: openmamba +Distribution: openmamba +Packager: Silvan Calarco +URL: http://www.linuxfoundation.org/collaborate/workgroups/networking/iproute2 +Source0: http://kernel.org/pub/linux/utils/net/iproute2/iproute2-%{version}.tar.xz +Source1: iproute2-tc.initscript +Source2: iproute2-traffic_control-sysconfig +Patch1: %{name}-2.6.20-makefile.patch +Patch2: %{name}-2.6.16-ip_resolve_crash.patch +Patch3: %{name}-2.6.20-tc_pfifo_man.patch +Patch4: %{name}-2.6.29-if_tunnel.patch +Patch5: %{name}-2.6.29-cross_fix.patch +Patch6: iproute-3.8.0-gcc-4.8.patch +License: GPL +## AUTOBUILDREQ-BEGIN +BuildRequires: glibc-devel +BuildRequires: iptables-devel +BuildRequires: libatm-devel +BuildRequires: libdb51-devel +## AUTOBUILDREQ-END +%if "%{stage1}" != "1" +BuildRequires: tetex-latex +BuildRequires: tetex-dvips +BuildRequires: linuxdoc-tools +BuildRequires: linuxdoc-tools-latex +%endif +BuildRequires: iptables >= 1.4.18 +BuildRequires: bison +BuildRequires: flex +Provides: iproute2 = %{?epoch:%epoch:}%{version}-%{release} +BuildRoot: %{_tmppath}/%{name}-%{version}-root + +%description +Iproute2 is a collection of utilities for controlling TCP / IP networking and Traffic Control in Linux. + +%package doc +Summary: Documentation for iproute2 +Group: Documentation + +%description doc +Iproute2 is a collection of utilities for controlling TCP / IP networking and Traffic Control in Linux. +This package contain the iproute2 documentation in dvi and html formats. + +%prep +%setup -q -n iproute2-%{version}%{?extraver!="-"} +#%patch1 -p1 -b .makefile +#%patch2 -p1 -b .ip_resolve_crash +#%patch3 -p1 -b .tc_pfifo_man +%patch4 -p1 +%patch5 -p1 +#%patch6 -p1 + +%build +%make \ + CC=%{_host}-gcc \ + SBINDIR=%{_sbindir} \ + MANDIR=%{_mandir} \ + DOCDIR=%{pckdocdir} \ +%if "%{_host}" != "%{_build}" + LIBDIR=%{_prefix}/%{_host}/ +%else + LIBDIR=%{_libdir} +%endif + +%if "%{stage1}" != "1" +%make -C doc dvi html +%endif + +%install +[ "%{buildroot}" != / ] && rm -rf "%{buildroot}" +%makeinstall \ + SBINDIR=%{_sbindir} \ + MANDIR=%{_mandir} \ + DOCDIR=%{pckdocdir} \ + LIBDIR=%{_libdir} + +install -D -m 0755 %{S:1} \ + %{buildroot}%{_initrddir}/tc +install -D -m 0644 %{S:2} \ + %{buildroot}%{_sysconfdir}/sysconfig/traffic_control + +install -d %{buildroot}/sbin +mv %{buildroot}%{_sbindir}/ip %{buildroot}/sbin +mv %{buildroot}%{_sbindir}/ifcfg %{buildroot}/sbin +mv %{buildroot}%{_sbindir}/rtmon %{buildroot}/sbin +mv %{buildroot}%{_sbindir}/tc %{buildroot}/sbin + +# remove unpackaged files +rm -f %{buildroot}%{pckdocdir}/*.tex +rm -f %{buildroot}%{pckdocdir}/*.sgml + +%clean +[ "%{buildroot}" != / ] && rm -rf "%{buildroot}" + +%preun +if [ $1 -eq 0 ]; then +# erase + /sbin/chkconfig tc + if [ $? -eq 0 ]; then + /sbin/service tc stop + /sbin/chkconfig --del tc + fi +fi +exit 0 + +%postun +if [ $1 -eq 1 ]; then +# upgrade + /sbin/chkconfig tc + [ $? -eq 0 ] && /sbin/service tc restart +fi +exit 0 + +%files +%defattr(-,root,root) +%config(noreplace) %{_sysconfdir}/sysconfig/traffic_control +%dir %{_sysconfdir}/iproute2 +%config %{_sysconfdir}/iproute2/* +%{_initrddir}/tc +/sbin/ifcfg +/sbin/ip +/sbin/tc +/sbin/rtmon +%{_sbindir}/arpd +%{_sbindir}/bridge +%{_sbindir}/ctstat +%{_sbindir}/genl +%{_sbindir}/ifstat +%{_sbindir}/lnstat +%{_sbindir}/nstat +%{_sbindir}/routef +%{_sbindir}/routel +%{_sbindir}/rtacct +%{_sbindir}/rtpr +%{_sbindir}/rtstat +%{_sbindir}/ss +%dir %{_libdir}/tc +%{_libdir}/tc/m_ipt.so +%{_libdir}/tc/m_xt.so +%{_libdir}/tc/q_atm.so +%{_libdir}/tc/experimental.dist +%{_libdir}/tc/normal.dist +%{_libdir}/tc/pareto.dist +%{_libdir}/tc/paretonormal.dist +#%{_libdir}/tc/q_atm.so +%{_mandir}/man3/libnetlink.* +%{_mandir}/man7/tc-hfsc.7* +%{_mandir}/man8/* +%doc COPYING + +%if "%{stage1}" != "1" +%files doc +%defattr(-,root,root) +%doc doc/*.dvi +%doc doc/*.html +%doc README +%doc examples/ +%endif + +%changelog +* Mon Dec 16 2013 Automatic Build System 3.12.0-1mamba +- automatic update by autodist + +* Sat Sep 07 2013 Automatic Build System 3.11.0-1mamba +- automatic update by autodist + +* Thu Aug 22 2013 Automatic Build System 3.10.0-1mamba +- automatic update by autodist + +* Fri Jun 07 2013 Automatic Build System 3.9.0-1mamba +- automatic version update by autodist + +* Sat May 11 2013 Automatic Build System 3.8.0-2mamba +- rebuilt with iptables 1.4.8 + +* Sat Mar 02 2013 Automatic Build System 3.8.0-1mamba +- automatic version update by autodist + +* Mon Dec 31 2012 Automatic Build System 3.7.0-1mamba +- automatic version update by autodist + +* Tue Oct 09 2012 Silvan Calarco 3.6.0-1mamba +- update to 3.6.0 + +* Tue Aug 14 2012 Automatic Build System 3.5.1-1mamba +- automatic version update by autodist + +* Sat Apr 28 2012 Silvan Calarco 3.3.0-1mamba +- update to 3.3.0 + +* Sun Oct 11 2009 Automatic Build System 2.6.29-1mamba +- automatic update to 2.6.29 by autodist + +* Mon May 18 2009 Automatic Build System 2.6.28-1mamba +- update to 2.6.28 + +* Fri Mar 06 2009 Silvan Calarco 2.6.26-2mamba +- initscript: use echo in place of gprintf + +* Tue Dec 30 2008 Silvan Calarco 2.6.26-1mamba +- update to 2.6.26 + +* Wed Jun 13 2007 Aleph0 2.6.20-2mamba +- add missing %defattr to doc subpackage +- fixed packager email address + +* Fri Mar 30 2007 Davide Madrisan 2.6.20-1mamba +- update to version 2.6.20 by autospec +- build binaries using the optflags gcc flags +- build the documentation provided by the package +- created a subpackage with the documentation in dvi and html formats +- ifcfg, tc, and rtmon moved to /sbin +- added missing build requirements + +* Wed Mar 01 2006 Silvan Calarco 2.6.15-1qilnx +- update to version 2.6.15 by autospec + +* Sat Sep 03 2005 Silvan Calarco 2.6.11-1qilnx +- update to version 2.6.11 by autospec +- ip: moved to /sbin dir + +* Fri Jul 30 2004 Silvan Calarco 2.6.8-1qilnx +- new version build taken from Stephen Hemminger repository +- added man installation + +* Thu Apr 29 2004 Silvan Calarco 2.4.7-3qilnx +- initscripts added + +* Tue Feb 17 2004 Davide Madrisan 2.4.7-2qilnx +- security errata for netlink (CAN-2003-0856): iproute2-2.4.7-netlink.patch + +* Mon Dec 15 2003 Silvan Calarco 2.4.7-1qilnx +- first build diff --git a/iproute2-tc.initscript b/iproute2-tc.initscript new file mode 100644 index 0000000..ab98f0e --- /dev/null +++ b/iproute2-tc.initscript @@ -0,0 +1,143 @@ +#!/bin/bash +# +# tc: apply the tc configuration rules +# +# Version: @(#) /etc/rc.d/init.d/tc +# +# chkconfig: 2345 90 10 +# description: Starts and stops the tc at boot time and shutdown. +# +# processname: tc +# +# created: from Raptor + +# path to the tc command +tc="/sbin/tc" +# where is the tc config file +tcConf="/etc/sysconfig/traffic_control" + +offMsg=OFF +onMsg=ON +debug=0 + +[ -x "$tc" ] || exit 1 + +# source function library +. /etc/sysconfig/rc +[ -r "$rc_functions" ] && . $rc_functions + +isUp () { + res=`$tc qdisc show dev $1` + [ "$res" ] || return 1 + return 0 +} + +start () { + echo -n "Starting tc services: " + OLDIFS="$IFS" + IFS="" + while read line; do + cmd=`echo $line | grep -v "^#" | sed -e "s/^tc//" | sed -e "s/^[ \t]*//"` + if [ -n "$cmd" ]; then + [ $debug -eq 1 ] && echo "Execute: $cmd:" + eval "$tc $cmd" + fi + done < $tcConf + touch /var/lock/subsys/tc + IFS="$OLDIFS" + evaluate_retval + echo +} + + +stop () { + echo -n "Stopping some/all tc services: " + # if explictly specified shut only these devices + [ "$1" ] && devs=$*; + #echo $devs + for d in $devs; do + if isUp $d ; then + echo -n "Flushing: $d" + $tc qdisc del root dev $d + $CURS_UP + evaluate_retval + echo + else + echo -n "No traffic control running on: $d" + evaluate_retval + echo + fi + done + # this is not the correct behavior + rm -f /var/lock/subsys/tc +} + + +status () { + [ "$1" ] && devs=$* + #echo $devs + for d in $devs; do + if isUp $d; then + echo "traffic control on $d: [$onMsg]" + else + echo "traffic control on $d: [$offMsg]" + fi + done +} + +show () { + if [ -z "$1" ]; then what=all; else what=$1; fi + shift + if [ "$1" ]; then devs=$*; fi + for d in $devs; do + if isUp $d; then + [ "$what" = "all" ] || [ "$what" = "qdisc" ] && + echo "`$tc qdisc show dev $d`" + [ "$what" = "all" ] || [ "$what" = "class" ] && + echo "`$tc class show dev $d`" + [ "$what" = "all" ] || [ "$what" = "filter" ] && + echo "`$tc filter show dev $d`" + fi + done +} + +parse () { + echo "$1" | perl -ne ' + $_ =~ s/(\d+?:\d+?)/$1/gs; + print $_ + ' +} + +stat () { + [ -z "$1" ] || [ -z "$2" ] && + echo "qdisc|class or device has to be specified !!!" && exit + parse "`$tc -s $1 show dev $2`" +} + +devs=`ifconfig -a | grep '^\w' | grep -v lo | cut -f 1 -d ' '` +command=$1 +shift + +case "$command" in + start) start ;; + stop) stop $@ ;; + status) status $@ ;; + show) show $@ ;; + stat) stat $@ ;; + restart) + echo -n "Restarting tc." + stop $@ + start $@ + ;; + *) + echo "*** Usage: + tc {start|stop|status|restart} [devices] + tc show [all|qdisc|class|filter] [devices] + tc stat [qdisc|class] [devices] +" + exit 1 + ;; +esac + +exit 0 + diff --git a/iproute2-traffic_control-sysconfig b/iproute2-traffic_control-sysconfig new file mode 100644 index 0000000..e3f2cf4 --- /dev/null +++ b/iproute2-traffic_control-sysconfig @@ -0,0 +1,35 @@ +# +# tc configuration file +# +# this file is loaded by the tc initscript (/etc/rc.d/init.d/tc) upon start +# note: only tc add commands are allowed here, tc del is done by the tc initscript + +# sample configuration + +# DOWNSTREAM + +#tc qdisc add dev eth1 root handle 1:0 cbq bandwidth 100mbit avpkt 1000 cell 8 +#tc class add dev eth1 parent 1:0 classid 1:1 cbq bandwidth 100mbit rate 2mbit allot 1514 weight 200kbit prio 8 maxburst 20 avpkt 1000 bounded +#tc class add dev eth1 parent 1:1 classid 1:10 cbq bandwidth 100mbit rate 1mbit allot 1514 weight 100kbit prio 8 maxburst 20 avpkt 1000 +#tc class add dev eth1 parent 1:1 classid 1:20 cbq bandwidth 100mbit rate 500kbit allot 1514 weight 50kbit prio 8 maxburst 20 avpkt 1000 +#tc class add dev eth1 parent 1:1 classid 1:30 cbq bandwidth 100mbit rate 500kbit allot 1514 weight 50kbit prio 8 maxburst 20 avpkt 1000 +#tc qdisc add dev eth1 parent 1:10 sfq quantum 1514b perturb 15 +#tc qdisc add dev eth1 parent 1:20 sfq quantum 1514b perturb 15 +#tc qdisc add dev eth1 parent 1:30 sfq quantum 1514b perturb 15 +#tc filter add dev eth1 parent 1:0 protocol ip prio 5 u32 match ip dport 80 0xffff flowid 1:10 +#tc filter add dev eth1 parent 1:0 protocol ip prio 5 u32 match ip dport 25 0xffff flowid 1:20 +#tc filter add dev eth1 parent 1:0 protocol ip prio 5 u32 match ip protocol 0 0xff flowid 1:30 + +# UPSTREAM + +#tc qdisc add dev eth0 root handle 1:0 cbq bandwidth 100mbit avpkt 1000 cell 8 +#tc class add dev eth0 parent 1:0 classid 1:1 cbq bandwidth 100mbit rate 2mbit allot 1514 weight 200kbit prio 8 maxburst 20 avpkt 1000 bounded +#tc class add dev eth0 parent 1:1 classid 1:10 cbq bandwidth 100mbit rate 1mbit allot 1514 weight 100kbit prio 8 maxburst 20 avpkt 1000 +#tc class add dev eth0 parent 1:1 classid 1:20 cbq bandwidth 100mbit rate 500kbit allot 1514 weight 50kbit prio 8 maxburst 20 avpkt 1000 +#tc class add dev eth0 parent 1:1 classid 1:30 cbq bandwidth 100mbit rate 500kbit allot 1514 weight 50kbit prio 8 maxburst 20 avpkt 1000 +#tc qdisc add dev eth0 parent 1:10 sfq quantum 1514b perturb 15 +#tc qdisc add dev eth0 parent 1:20 sfq quantum 1514b perturb 15 +#tc qdisc add dev eth0 parent 1:30 sfq quantum 1514b perturb 15 +#tc filter add dev eth0 parent 1:0 protocol ip prio 5 u32 match ip sport 80 0xffff flowid 1:10 +#tc filter add dev eth0 parent 1:0 protocol ip prio 5 u32 match ip sport 25 0xffff flowid 1:20 +#tc filter add dev eth0 parent 1:0 protocol ip prio 5 u32 match ip protocol 0 0xff flowid 1:30