summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--accel-pppd/ifcfg.c32
-rw-r--r--accel-pppd/libnetlink/iputils.c4
-rw-r--r--accel-pppd/libnetlink/iputils.h2
3 files changed, 4 insertions, 34 deletions
diff --git a/accel-pppd/ifcfg.c b/accel-pppd/ifcfg.c
index 109751a..3035e13 100644
--- a/accel-pppd/ifcfg.c
+++ b/accel-pppd/ifcfg.c
@@ -74,7 +74,6 @@ void __export ap_session_accounting_started(struct ap_session *ses)
//struct rtentry rt;
struct in6_ifreq ifr6;
struct npioctl np;
- struct sockaddr_in addr;
struct ppp_t *ppp;
if (ses->stop_time)
@@ -105,37 +104,8 @@ void __export ap_session_accounting_started(struct ap_session *ses)
if (!ses->backup || !ses->backup->internal) {
#endif
if (ses->ipv4) {
- memset(&addr, 0, sizeof(addr));
- addr.sin_family = AF_INET;
- addr.sin_addr.s_addr = ses->ipv4->addr;
- memcpy(&ifr.ifr_addr, &addr, sizeof(addr));
-
- if (net->sock_ioctl(SIOCSIFADDR, &ifr))
+ 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->ctrl->type == CTRL_TYPE_IPOE) {
- addr.sin_addr.s_addr = 0xffffffff;
- memcpy(&ifr.ifr_netmask, &addr, sizeof(addr));
- if (ioctl(sock_fd, SIOCSIFNETMASK, &ifr))
- log_ppp_error("failed to set IPv4 nask: %s\n", strerror(errno));
- }*/
-
- addr.sin_addr.s_addr = ses->ipv4->peer_addr;
-
- /*if (ses->ctrl->type == CTRL_TYPE_IPOE) {
- memset(&rt, 0, sizeof(rt));
- memcpy(&rt.rt_dst, &addr, sizeof(addr));
- rt.rt_flags = RTF_HOST | RTF_UP;
- rt.rt_metric = 1;
- rt.rt_dev = ifr.ifr_name;
- if (ioctl(sock_fd, SIOCADDRT, &rt, sizeof(rt)))
- log_ppp_error("failed to add route: %s\n", strerror(errno));
- } else*/ {
- memcpy(&ifr.ifr_dstaddr, &addr, sizeof(addr));
-
- if (net->sock_ioctl(SIOCSIFDSTADDR, &ifr))
- log_ppp_error("failed to set peer IPv4 address: %s\n", strerror(errno));
- }
}
if (ses->ipv6) {
diff --git a/accel-pppd/libnetlink/iputils.c b/accel-pppd/libnetlink/iputils.c
index ad6005f..1f0592c 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 __export ipaddr_add_peer(int ifindex, in_addr_t addr, in_addr_t peer_addr, int mask)
{
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)
req.n.nlmsg_type = RTM_NEWADDR;
req.i.ifa_family = AF_INET;
req.i.ifa_index = ifindex;
- req.i.ifa_prefixlen = 32;
+ req.i.ifa_prefixlen = mask;
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 66aa974..9451b06 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 ipaddr_add_peer(int ifindex, in_addr_t addr, in_addr_t peer_addr, int mask);
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);