summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--accel-pppd/ifcfg.c9
-rw-r--r--accel-pppd/libnetlink/iputils.c4
-rw-r--r--accel-pppd/libnetlink/iputils.h2
3 files changed, 10 insertions, 5 deletions
diff --git a/accel-pppd/ifcfg.c b/accel-pppd/ifcfg.c
index 3035e13..03968fb 100644
--- a/accel-pppd/ifcfg.c
+++ b/accel-pppd/ifcfg.c
@@ -104,8 +104,13 @@ void __export ap_session_accounting_started(struct ap_session *ses)
if (!ses->backup || !ses->backup->internal) {
#endif
if (ses->ipv4) {
- if (ipaddr_add_peer(ses->ifindex, ses->ipv4->addr, ses->ipv4->peer_addr, ses->ipv4->mask ?: 32))
- log_ppp_error("failed to set IPv4 address: %s\n", strerror(errno));
+ if (ses->ipv4->mask == 0 || ses->ipv4->mask == 32) {
+ if (ipaddr_add_peer(ses->ifindex, ses->ipv4->addr, ses->ipv4->peer_addr))
+ log_ppp_error("failed to set IPv4 address: %s\n", strerror(errno));
+ } else {
+ if (ipaddr_add(ses->ifindex, ses->ipv4->addr, ses->ipv4->mask))
+ log_ppp_error("failed to set IPv4 address: %s\n", strerror(errno));
+ }
}
if (ses->ipv6) {
diff --git a/accel-pppd/libnetlink/iputils.c b/accel-pppd/libnetlink/iputils.c
index 1f0592c..ad6005f 100644
--- a/accel-pppd/libnetlink/iputils.c
+++ b/accel-pppd/libnetlink/iputils.c
@@ -359,7 +359,7 @@ int __export ipaddr_add(int ifindex, in_addr_t addr, int mask)
return r;
}
-int __export ipaddr_add_peer(int ifindex, in_addr_t addr, in_addr_t peer_addr, int mask)
+int __export ipaddr_add_peer(int ifindex, in_addr_t addr, in_addr_t peer_addr)
{
struct ipaddr_req {
struct nlmsghdr n;
@@ -379,7 +379,7 @@ int __export ipaddr_add_peer(int ifindex, in_addr_t addr, in_addr_t peer_addr, i
req.n.nlmsg_type = RTM_NEWADDR;
req.i.ifa_family = AF_INET;
req.i.ifa_index = ifindex;
- req.i.ifa_prefixlen = mask;
+ req.i.ifa_prefixlen = 32;
addattr32(&req.n, sizeof(req), IFA_LOCAL, addr);
addattr32(&req.n, sizeof(req), IFA_ADDRESS, peer_addr);
diff --git a/accel-pppd/libnetlink/iputils.h b/accel-pppd/libnetlink/iputils.h
index 9451b06..66aa974 100644
--- a/accel-pppd/libnetlink/iputils.h
+++ b/accel-pppd/libnetlink/iputils.h
@@ -14,7 +14,7 @@ int iplink_vlan_del(int ifindex);
int iplink_vlan_get_vid(int ifindex, int *iflink);
int ipaddr_add(int ifindex, in_addr_t addr, int mask);
-int ipaddr_add_peer(int ifindex, in_addr_t addr, in_addr_t peer_addr, int mask);
+int ipaddr_add_peer(int ifindex, in_addr_t addr, in_addr_t peer_addr);
int ipaddr_del(int ifindex, in_addr_t addr, int mask);
int ipaddr_del_peer(int ifindex, in_addr_t addr, in_addr_t peer);