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