aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4
diff options
context:
space:
mode:
Diffstat (limited to 'net/ipv4')
-rw-r--r--net/ipv4/devinet.c34
-rw-r--r--net/ipv4/multipath_drr.c18
-rw-r--r--net/ipv4/multipath_rr.c20
3 files changed, 30 insertions, 42 deletions
diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
index 3cc96730c4ed..478a30179a52 100644
--- a/net/ipv4/devinet.c
+++ b/net/ipv4/devinet.c
@@ -233,11 +233,14 @@ int inet_addr_onlink(struct in_device *in_dev, u32 a, u32 b)
233static void inet_del_ifa(struct in_device *in_dev, struct in_ifaddr **ifap, 233static void inet_del_ifa(struct in_device *in_dev, struct in_ifaddr **ifap,
234 int destroy) 234 int destroy)
235{ 235{
236 struct in_ifaddr *promote = NULL;
236 struct in_ifaddr *ifa1 = *ifap; 237 struct in_ifaddr *ifa1 = *ifap;
237 238
238 ASSERT_RTNL(); 239 ASSERT_RTNL();
239 240
240 /* 1. Deleting primary ifaddr forces deletion all secondaries */ 241 /* 1. Deleting primary ifaddr forces deletion all secondaries
242 * unless alias promotion is set
243 **/
241 244
242 if (!(ifa1->ifa_flags & IFA_F_SECONDARY)) { 245 if (!(ifa1->ifa_flags & IFA_F_SECONDARY)) {
243 struct in_ifaddr *ifa; 246 struct in_ifaddr *ifa;
@@ -251,11 +254,16 @@ static void inet_del_ifa(struct in_device *in_dev, struct in_ifaddr **ifap,
251 continue; 254 continue;
252 } 255 }
253 256
254 *ifap1 = ifa->ifa_next; 257 if (!IN_DEV_PROMOTE_SECONDARIES(in_dev)) {
258 *ifap1 = ifa->ifa_next;
255 259
256 rtmsg_ifa(RTM_DELADDR, ifa); 260 rtmsg_ifa(RTM_DELADDR, ifa);
257 notifier_call_chain(&inetaddr_chain, NETDEV_DOWN, ifa); 261 notifier_call_chain(&inetaddr_chain, NETDEV_DOWN, ifa);
258 inet_free_ifa(ifa); 262 inet_free_ifa(ifa);
263 } else {
264 promote = ifa;
265 break;
266 }
259 } 267 }
260 } 268 }
261 269
@@ -281,6 +289,13 @@ static void inet_del_ifa(struct in_device *in_dev, struct in_ifaddr **ifap,
281 if (!in_dev->ifa_list) 289 if (!in_dev->ifa_list)
282 inetdev_destroy(in_dev); 290 inetdev_destroy(in_dev);
283 } 291 }
292
293 if (promote && IN_DEV_PROMOTE_SECONDARIES(in_dev)) {
294 /* not sure if we should send a delete notify first? */
295 promote->ifa_flags &= ~IFA_F_SECONDARY;
296 rtmsg_ifa(RTM_NEWADDR, promote);
297 notifier_call_chain(&inetaddr_chain, NETDEV_UP, promote);
298 }
284} 299}
285 300
286static int inet_insert_ifa(struct in_ifaddr *ifa) 301static int inet_insert_ifa(struct in_ifaddr *ifa)
@@ -1384,6 +1399,15 @@ static struct devinet_sysctl_table {
1384 .proc_handler = &ipv4_doint_and_flush, 1399 .proc_handler = &ipv4_doint_and_flush,
1385 .strategy = &ipv4_doint_and_flush_strategy, 1400 .strategy = &ipv4_doint_and_flush_strategy,
1386 }, 1401 },
1402 {
1403 .ctl_name = NET_IPV4_CONF_PROMOTE_SECONDARIES,
1404 .procname = "promote_secondaries",
1405 .data = &ipv4_devconf.promote_secondaries,
1406 .maxlen = sizeof(int),
1407 .mode = 0644,
1408 .proc_handler = &ipv4_doint_and_flush,
1409 .strategy = &ipv4_doint_and_flush_strategy,
1410 },
1387 }, 1411 },
1388 .devinet_dev = { 1412 .devinet_dev = {
1389 { 1413 {
diff --git a/net/ipv4/multipath_drr.c b/net/ipv4/multipath_drr.c
index 9349686131fc..cf2e6bcf7973 100644
--- a/net/ipv4/multipath_drr.c
+++ b/net/ipv4/multipath_drr.c
@@ -57,7 +57,6 @@ struct multipath_device {
57 57
58static struct multipath_device state[MULTIPATH_MAX_DEVICECANDIDATES]; 58static struct multipath_device state[MULTIPATH_MAX_DEVICECANDIDATES];
59static DEFINE_SPINLOCK(state_lock); 59static DEFINE_SPINLOCK(state_lock);
60static struct rtable *last_selection = NULL;
61 60
62static int inline __multipath_findslot(void) 61static int inline __multipath_findslot(void)
63{ 62{
@@ -111,11 +110,6 @@ struct notifier_block drr_dev_notifier = {
111 .notifier_call = drr_dev_event, 110 .notifier_call = drr_dev_event,
112}; 111};
113 112
114static void drr_remove(struct rtable *rt)
115{
116 if (last_selection == rt)
117 last_selection = NULL;
118}
119 113
120static void drr_safe_inc(atomic_t *usecount) 114static void drr_safe_inc(atomic_t *usecount)
121{ 115{
@@ -144,14 +138,6 @@ static void drr_select_route(const struct flowi *flp,
144 int devidx = -1; 138 int devidx = -1;
145 int cur_min_devidx = -1; 139 int cur_min_devidx = -1;
146 140
147 /* if necessary and possible utilize the old alternative */
148 if ((flp->flags & FLOWI_FLAG_MULTIPATHOLDROUTE) != 0 &&
149 last_selection != NULL) {
150 result = last_selection;
151 *rp = result;
152 return;
153 }
154
155 /* 1. make sure all alt. nexthops have the same GC related data */ 141 /* 1. make sure all alt. nexthops have the same GC related data */
156 /* 2. determine the new candidate to be returned */ 142 /* 2. determine the new candidate to be returned */
157 result = NULL; 143 result = NULL;
@@ -229,12 +215,10 @@ static void drr_select_route(const struct flowi *flp,
229 } 215 }
230 216
231 *rp = result; 217 *rp = result;
232 last_selection = result;
233} 218}
234 219
235static struct ip_mp_alg_ops drr_ops = { 220static struct ip_mp_alg_ops drr_ops = {
236 .mp_alg_select_route = drr_select_route, 221 .mp_alg_select_route = drr_select_route,
237 .mp_alg_remove = drr_remove,
238}; 222};
239 223
240static int __init drr_init(void) 224static int __init drr_init(void)
@@ -244,7 +228,7 @@ static int __init drr_init(void)
244 if (err) 228 if (err)
245 return err; 229 return err;
246 230
247 err = multipath_alg_register(&drr_ops, IP_MP_ALG_RR); 231 err = multipath_alg_register(&drr_ops, IP_MP_ALG_DRR);
248 if (err) 232 if (err)
249 goto fail; 233 goto fail;
250 234
diff --git a/net/ipv4/multipath_rr.c b/net/ipv4/multipath_rr.c
index 554a82568160..061b6b253982 100644
--- a/net/ipv4/multipath_rr.c
+++ b/net/ipv4/multipath_rr.c
@@ -47,29 +47,12 @@
47#include <net/checksum.h> 47#include <net/checksum.h>
48#include <net/ip_mp_alg.h> 48#include <net/ip_mp_alg.h>
49 49
50#define MULTIPATH_MAX_CANDIDATES 40
51
52static struct rtable* last_used = NULL;
53
54static void rr_remove(struct rtable *rt)
55{
56 if (last_used == rt)
57 last_used = NULL;
58}
59
60static void rr_select_route(const struct flowi *flp, 50static void rr_select_route(const struct flowi *flp,
61 struct rtable *first, struct rtable **rp) 51 struct rtable *first, struct rtable **rp)
62{ 52{
63 struct rtable *nh, *result, *min_use_cand = NULL; 53 struct rtable *nh, *result, *min_use_cand = NULL;
64 int min_use = -1; 54 int min_use = -1;
65 55
66 /* if necessary and possible utilize the old alternative */
67 if ((flp->flags & FLOWI_FLAG_MULTIPATHOLDROUTE) != 0 &&
68 last_used != NULL) {
69 result = last_used;
70 goto out;
71 }
72
73 /* 1. make sure all alt. nexthops have the same GC related data 56 /* 1. make sure all alt. nexthops have the same GC related data
74 * 2. determine the new candidate to be returned 57 * 2. determine the new candidate to be returned
75 */ 58 */
@@ -90,15 +73,12 @@ static void rr_select_route(const struct flowi *flp,
90 if (!result) 73 if (!result)
91 result = first; 74 result = first;
92 75
93out:
94 last_used = result;
95 result->u.dst.__use++; 76 result->u.dst.__use++;
96 *rp = result; 77 *rp = result;
97} 78}
98 79
99static struct ip_mp_alg_ops rr_ops = { 80static struct ip_mp_alg_ops rr_ops = {
100 .mp_alg_select_route = rr_select_route, 81 .mp_alg_select_route = rr_select_route,
101 .mp_alg_remove = rr_remove,
102}; 82};
103 83
104static int __init rr_init(void) 84static int __init rr_init(void)