1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
From f63ef90aefd8142c7b2ea2e3cd1abae375fc46b5 Mon Sep 17 00:00:00 2001
From: Natanael Copa <ncopa@alpinelinux.org>
Date: Wed, 1 Aug 2012 12:03:05 +0000
Subject: [PATCH] pingu_route: allow default routes that has no via address
This fixes load-balancing with ppp0
We also make the via address family (ipv4/ipv6) agnostic.
---
pingu_netlink.c | 10 ++++++----
pingu_route.c | 3 +--
2 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/pingu_netlink.c b/pingu_netlink.c
index e3afbf6..dc4a2ed 100644
--- a/pingu_netlink.c
+++ b/pingu_netlink.c
@@ -138,7 +138,7 @@ static int netlink_add_subrtattr_l(struct rtattr *rta, int maxlen, int type,
subrta->rta_len = len;
memcpy(RTA_DATA(subrta), data, alen);
rta->rta_len = NLMSG_ALIGN(rta->rta_len) + RTA_ALIGN(len);
- return TRUE;
+ return alen;
}
static int netlink_add_subrtattr_addr_any(struct rtattr *rta, int maxlen,
@@ -346,11 +346,13 @@ static int add_one_nh(struct rtattr *rta, struct rtnexthop *rtnh,
struct pingu_iface *iface,
struct pingu_route *route)
{
+ int addr_size;
if (route == NULL)
return 0;
- netlink_add_subrtattr_addr_any(rta, 1024, RTA_GATEWAY,
- &route->gw_addr);
- rtnh->rtnh_len += sizeof(struct rtattr) + 4; // TODO: support ipv6
+ addr_size = netlink_add_subrtattr_addr_any(rta, 1024, RTA_GATEWAY,
+ &route->gw_addr);
+ if (addr_size > 0)
+ rtnh->rtnh_len += sizeof(struct rtattr) + addr_size;
if (iface->balance_weight)
rtnh->rtnh_hops = iface->balance_weight - 1;
rtnh->rtnh_ifindex = iface->index;
diff --git a/pingu_route.c b/pingu_route.c
index 3a82f70..a2462c1 100644
--- a/pingu_route.c
+++ b/pingu_route.c
@@ -126,8 +126,7 @@ int is_default_gw(struct pingu_route *route)
{
switch (route->dest.sa.sa_family) {
case AF_INET:
- return ((route->dest.sin.sin_addr.s_addr == 0)
- && (route->gw_addr.sin.sin_addr.s_addr != 0));
+ return (route->dest.sin.sin_addr.s_addr == 0);
break;
case AF_INET6:
log_debug("TODO: ipv6");
--
1.7.11.2
|