]> TLD Linux GIT Repositories - packages/rc-scripts.git/blob - rc-scripts-net-bond.patch
- more fixes, details in patch commit logs
[packages/rc-scripts.git] / rc-scripts-net-bond.patch
1 diff -urN rc-scripts-0.4.12.orig/lib/ifdown rc-scripts-0.4.12/lib/ifdown
2 --- rc-scripts-0.4.12.orig/lib/ifdown   2014-06-10 06:55:19.000000000 +0000
3 +++ rc-scripts-0.4.12/lib/ifdown        2014-07-12 18:44:23.637000000 +0000
4 @@ -118,25 +118,6 @@
5         ip addr del ${IP4ADDR} label ${SUBDEVICE} dev ${DEVICE}
6  else
7         LC_ALL=C ip addr flush dev ${DEVICE} 2>&1 | grep -v "Nothing to flush"
8 -
9 -       if [ ${DEVICETYPE} = "bond" ]; then
10 -               if [ ! -x /sbin/ifenslave ]; then
11 -                       nls "%s is missing. Can't continue." "/sbin/ifenslave"
12 -                       exit 1
13 -               fi
14 -
15 -               # get up the bonding device before enslaving
16 -               if ! check_device_down "${DEVICE}"; then
17 -                       ip link set ${DEVICE} up
18 -               fi
19 -
20 -               for BSVAR in $(awk '/Slave Interface:/{ print $3}' /proc/net/bonding/${DEVICE}); do
21 -                       if [ "${BSVAR}" ]; then
22 -                               ifenslave -d ${DEVICE} $BSVAR
23 -                       fi
24 -               done
25 -       fi
26 -
27         ip link set ${DEVICE} down
28  fi
29  
30 diff -urN rc-scripts-0.4.12.orig/lib/ifdown-bond rc-scripts-0.4.12/lib/ifdown-bond
31 --- rc-scripts-0.4.12.orig/lib/ifdown-bond      1970-01-01 00:00:00.000000000 +0000
32 +++ rc-scripts-0.4.12/lib/ifdown-bond   2014-07-12 22:00:34.509000000 +0000
33 @@ -0,0 +1,54 @@
34 +#!/bin/sh
35 +#
36 +#    ifdown-bond - bonding configuration script
37 +#    Copyright (C) 2014 Marcin Krol <hawk@tld-linux.org>
38 +#
39 +#    This program is free software; you can redistribute it and/or modify
40 +#    it under the terms of the GNU General Public License as published by
41 +#    the Free Software Foundation; either version 2 of the License, or
42 +#    (at your option) any later version.
43 +#
44 +#    This program is distributed in the hope that it will be useful,
45 +#    but WITHOUT ANY WARRANTY; without even the implied warranty of
46 +#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
47 +#    GNU General Public License for more details.
48 +#
49 +#    You should have received a copy of the GNU General Public License
50 +#    along with this program; if not, write to the Free Software
51 +#    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
52 +#
53 +#
54 +PATH=/sbin:/usr/sbin:/bin:/usr/bin
55 +
56 +. /etc/sysconfig/network
57 +. /etc/rc.d/init.d/functions
58 +. /lib/rc-scripts/functions.network
59 +
60 +CONFIG=$1
61 +source_config
62 +
63 +if [ "x${2}" = "xboot" ] && is_no "${ONBOOT}"; then
64 +       exit
65 +fi
66 +
67 +# set all major variables
68 +setup_ip_param
69 +
70 +# forget all addresses
71 +LC_ALL=C ip addr flush dev ${DEVICE} 2>&1 | grep -v "Nothing to flush"
72 +
73 +# release slave devices
74 +for SLAVE_DEV in $(cat /sys/class/net/${DEVICE}/bonding/slaves); do
75 +       echo "-${SLAVE_DEV}" > /sys/class/net/${DEVICE}/bonding/slaves
76 +done
77 +
78 +# bring bonding master down
79 +ip link set ${DEVICE} down
80 +
81 +# remove bonding master
82 +if grep -wq "${DEVICE}" /sys/class/net/bonding_masters; then
83 +       echo "-${DEVICE}" > /sys/class/net/bonding_masters
84 +       if [ $? -ne 0 ]; then
85 +               exit 1
86 +       fi
87 +fi
88 diff -urN rc-scripts-0.4.12.orig/lib/ifup rc-scripts-0.4.12/lib/ifup
89 --- rc-scripts-0.4.12.orig/lib/ifup     2014-06-10 06:55:19.000000000 +0000
90 +++ rc-scripts-0.4.12/lib/ifup  2014-07-12 21:58:42.147000000 +0000
91 @@ -89,18 +89,12 @@
92         exit 1
93  fi
94  
95 -if is_yes "$SLAVE" && [ ! -x /sbin/ifenslave ]; then
96 -       nls "%s is missing. Can't continue." "/sbin/ifenslave"
97 -       exit 1
98 -fi
99 -
100 -if is_yes "$SLAVE" && [ -n "$MASTER" -a -x /sbin/ifenslave ]; then
101 -       RFLAG="" && is_yes "${RECIEVE-ONLY}" && RFLAG="-r"
102 -
103 -       ip link set ${DEVICE} down
104 -       nls "Enslaving %s to %s" "$DEVICE" "$MASTER"
105 -       ifenslave $RFLAG "$MASTER" "$DEVICE"
106 -
107 +if is_yes "$SLAVE" && [ -n "$MASTER" ]; then
108 +       if ! grep -wq "${DEVICE}" /sys/class/net/${MASTER}/bonding/slaves 2>/dev/null; then
109 +               nls "Enslaving %s to %s" "$DEVICE" "$MASTER"
110 +               ip link set dev ${DEVICE} down
111 +               echo "+${DEVICE}" > /sys/class/net/${MASTER}/bonding/slaves 2>/dev/null
112 +       fi
113         if [ -n "$ETHTOOL_OPTS" ] ; then
114                 /sbin/ethtool -s $DEVICE $ETHTOOL_OPTS
115         fi
116 diff -urN rc-scripts-0.4.12.orig/lib/ifup-bond rc-scripts-0.4.12/lib/ifup-bond
117 --- rc-scripts-0.4.12.orig/lib/ifup-bond        1970-01-01 00:00:00.000000000 +0000
118 +++ rc-scripts-0.4.12/lib/ifup-bond     2014-07-12 22:08:02.953000000 +0000
119 @@ -0,0 +1,75 @@
120 +#!/bin/sh
121 +#
122 +#    ifup-bond - bonding configuration script
123 +#    Copyright (C) 2014 Marcin Krol <hawk@tld-linux.org>
124 +#
125 +#    This program is free software; you can redistribute it and/or modify
126 +#    it under the terms of the GNU General Public License as published by
127 +#    the Free Software Foundation; either version 2 of the License, or
128 +#    (at your option) any later version.
129 +#
130 +#    This program is distributed in the hope that it will be useful,
131 +#    but WITHOUT ANY WARRANTY; without even the implied warranty of
132 +#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
133 +#    GNU General Public License for more details.
134 +#
135 +#    You should have received a copy of the GNU General Public License
136 +#    along with this program; if not, write to the Free Software
137 +#    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
138 +#
139 +#
140 +PATH=/sbin:/usr/sbin:/bin:/usr/bin
141 +
142 +. /etc/sysconfig/network
143 +. /etc/rc.d/init.d/functions
144 +. /lib/rc-scripts/functions.network
145 +
146 +CONFIG=$1
147 +source_config
148 +
149 +if [ "x${2}" = "xboot" ] && is_no "${ONBOOT}"; then
150 +       exit
151 +fi
152 +
153 +# check for bonding support
154 +if [ ! -f /sys/class/net/bonding_masters ]; then
155 +       modprobe -s bonding || exit 1
156 +       # delete default bond0
157 +       echo "-bond0" > /sys/class/net/bonding_masters
158 +fi
159 +
160 +# set all major variables
161 +setup_ip_param
162 +
163 +# create bonding master
164 +if ! grep -wq "${DEVICE}" /sys/class/net/bonding_masters; then
165 +       echo "+${DEVICE}" > /sys/class/net/bonding_masters
166 +       if [ $? -eq 0 ]; then
167 +               ip link set dev ${DEVICE} multicast ${MULTICAST} ${ARP}
168 +       else
169 +               exit 1
170 +       fi
171 +fi
172 +
173 +# add the bits to setup driver parameters here
174 +# taken from Fedora initscripts
175 +for arg in ${BONDING_OPTS} ; do
176 +       key=${arg%%=*};
177 +       value=${arg##*=};
178 +       if [ "${key}" = "arp_ip_target" -a "${value:0:1}" != "+" ]; then
179 +               OLDIFS=$IFS;
180 +               IFS=',';
181 +               for arp_ip in $value; do
182 +                       if ! grep -q $arp_ip /sys/class/net/${DEVICE}/bonding/$key; then
183 +                               echo +$arp_ip > /sys/class/net/${DEVICE}/bonding/$key
184 +                       fi
185 +               done
186 +               IFS=$OLDIFS;
187 +       elif [ "${key}" = "arp_ip_target" ]; then
188 +               if ! grep -q ${value#+} /sys/class/net/${DEVICE}/bonding/$key; then
189 +                       echo "$value" > /sys/class/net/${DEVICE}/bonding/$key
190 +               fi
191 +       elif [ "${key}" != "primary" ]; then
192 +               echo $value > /sys/class/net/${DEVICE}/bonding/$key
193 +       fi
194 +done
195 diff -urN rc-scripts-0.4.12.orig/lib/Makefile.am rc-scripts-0.4.12/lib/Makefile.am
196 --- rc-scripts-0.4.12.orig/lib/Makefile.am      2013-11-02 20:50:20.000000000 +0000
197 +++ rc-scripts-0.4.12/lib/Makefile.am   2014-07-12 22:01:57.571000000 +0000
198 @@ -10,6 +10,7 @@
199  scriptsdir = @exec_prefix@/lib/$(PACKAGE)
200  
201  scripts_SCRIPTS = \
202 +       ifdown-bond \
203         ifdown-br \
204         ifdown-irda \
205         ifdown-ppp \
206 @@ -17,6 +18,7 @@
207         ifdown-sl \
208         ifdown-vlan \
209         ifup-aliases \
210 +       ifup-bond \
211         ifup-br \
212         ifup-ipx \
213         ifup-irda \
214 diff -urN rc-scripts-0.4.12.orig/lib/Makefile.in rc-scripts-0.4.12/lib/Makefile.in
215 --- rc-scripts-0.4.12.orig/lib/Makefile.in      2014-07-12 11:45:17.000000000 +0000
216 +++ rc-scripts-0.4.12/lib/Makefile.in   2014-07-12 22:01:50.605000000 +0000
217 @@ -256,6 +256,7 @@
218  #scriptsdir = @networkscriptsdir@
219  scriptsdir = @exec_prefix@/lib/$(PACKAGE)
220  scripts_SCRIPTS = \
221 +       ifdown-bond \
222         ifdown-br \
223         ifdown-irda \
224         ifdown-ppp \
225 @@ -263,6 +264,7 @@
226         ifdown-sl \
227         ifdown-vlan \
228         ifup-aliases \
229 +       ifup-bond \
230         ifup-br \
231         ifup-ipx \
232         ifup-irda \