summaryrefslogtreecommitdiff
path: root/accel-pppd/ifcfg.c
diff options
context:
space:
mode:
authorKozlov Dmitry <xeb@mail.ru>2012-07-15 02:21:07 +0400
committerKozlov Dmitry <xeb@mail.ru>2012-07-15 02:21:07 +0400
commite687bb04784040fb26c231540e3c7b3ad9fd73d9 (patch)
treef0fce402e40b2043add9d59c8b9b811aa212b112 /accel-pppd/ifcfg.c
parent177d7a666c96c66cadc44917654a7892dbad9150 (diff)
downloadaccel-ppp-xebd-e687bb04784040fb26c231540e3c7b3ad9fd73d9.tar.gz
accel-ppp-xebd-e687bb04784040fb26c231540e3c7b3ad9fd73d9.zip
ipoe: better support for ip unnumbered
Diffstat (limited to 'accel-pppd/ifcfg.c')
-rw-r--r--accel-pppd/ifcfg.c163
1 files changed, 84 insertions, 79 deletions
diff --git a/accel-pppd/ifcfg.c b/accel-pppd/ifcfg.c
index 0b4927b..ac88a0d 100644
--- a/accel-pppd/ifcfg.c
+++ b/accel-pppd/ifcfg.c
@@ -71,104 +71,106 @@ void ap_session_ifup(struct ap_session *ses)
if (ses->stop_time)
return;
- memset(&ifr, 0, sizeof(ifr));
- strcpy(ifr.ifr_name, ses->ifname);
+ if (!ses->ctrl->dont_ifcfg) {
+ memset(&ifr, 0, sizeof(ifr));
+ strcpy(ifr.ifr_name, ses->ifname);
#ifdef USE_BACKUP
- if (!ses->backup || !ses->backup->internal) {
+ 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 (ioctl(sock_fd, SIOCSIFADDR, &ifr))
- 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));
- }*/
+ 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 (ioctl(sock_fd, SIOCSIFADDR, &ifr))
+ log_ppp_error("failed to set IPv4 address: %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 (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));
+ }*/
- if (ioctl(sock_fd, SIOCSIFDSTADDR, &ifr))
- log_ppp_error("failed to set peer IPv4 address: %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 (ioctl(sock_fd, SIOCSIFDSTADDR, &ifr))
+ log_ppp_error("failed to set peer IPv4 address: %s\n", strerror(errno));
+ }
}
- }
-
- if (ses->ipv6) {
- devconf(ses, "accept_ra", "0");
- devconf(ses, "autoconf", "0");
- devconf(ses, "forwarding", "1");
- memset(&ifr6, 0, sizeof(ifr6));
-
- if (ses->ctrl->type != CTRL_TYPE_IPOE) {
- ifr6.ifr6_addr.s6_addr32[0] = htons(0xfe80);
- *(uint64_t *)(ifr6.ifr6_addr.s6_addr + 8) = ses->ipv6->intf_id;
- ifr6.ifr6_prefixlen = 64;
- ifr6.ifr6_ifindex = ses->ifindex;
+ if (ses->ipv6) {
+ devconf(ses, "accept_ra", "0");
+ devconf(ses, "autoconf", "0");
+ devconf(ses, "forwarding", "1");
- if (ioctl(sock6_fd, SIOCSIFADDR, &ifr6))
- log_ppp_error("faild to set LL IPv6 address: %s\n", strerror(errno));
- }
-
- list_for_each_entry(a, &ses->ipv6->addr_list, entry) {
- if (a->prefix_len == 128)
- continue;
+ memset(&ifr6, 0, sizeof(ifr6));
+
+ if (ses->ctrl->type != CTRL_TYPE_IPOE) {
+ ifr6.ifr6_addr.s6_addr32[0] = htons(0xfe80);
+ *(uint64_t *)(ifr6.ifr6_addr.s6_addr + 8) = ses->ipv6->intf_id;
+ ifr6.ifr6_prefixlen = 64;
+ ifr6.ifr6_ifindex = ses->ifindex;
+
+ if (ioctl(sock6_fd, SIOCSIFADDR, &ifr6))
+ log_ppp_error("faild to set LL IPv6 address: %s\n", strerror(errno));
+ }
+
+ list_for_each_entry(a, &ses->ipv6->addr_list, entry) {
+ if (a->prefix_len == 128)
+ continue;
- build_addr(a, ses->ipv6->intf_id, &ifr6.ifr6_addr);
- ifr6.ifr6_prefixlen = a->prefix_len;
+ build_addr(a, ses->ipv6->intf_id, &ifr6.ifr6_addr);
+ ifr6.ifr6_prefixlen = a->prefix_len;
- if (ioctl(sock6_fd, SIOCSIFADDR, &ifr6))
- log_ppp_error("failed to add IPv6 address: %s\n", strerror(errno));
+ if (ioctl(sock6_fd, SIOCSIFADDR, &ifr6))
+ log_ppp_error("failed to add IPv6 address: %s\n", strerror(errno));
+ }
}
- }
-
- if (ioctl(sock_fd, SIOCGIFFLAGS, &ifr))
- log_ppp_error("failed to get interface flags: %s\n", strerror(errno));
- ifr.ifr_flags |= IFF_UP;
+ if (ioctl(sock_fd, SIOCGIFFLAGS, &ifr))
+ log_ppp_error("failed to get interface flags: %s\n", strerror(errno));
- if (ioctl(sock_fd, SIOCSIFFLAGS, &ifr))
- log_ppp_error("failed to set interface flags: %s\n", strerror(errno));
+ ifr.ifr_flags |= IFF_UP;
- if (ses->ctrl->type != CTRL_TYPE_IPOE) {
- ppp = container_of(ses, typeof(*ppp), ses);
- if (ses->ipv4) {
- np.protocol = PPP_IP;
- np.mode = NPMODE_PASS;
+ if (ioctl(sock_fd, SIOCSIFFLAGS, &ifr))
+ log_ppp_error("failed to set interface flags: %s\n", strerror(errno));
- if (ioctl(ppp->unit_fd, PPPIOCSNPMODE, &np))
- log_ppp_error("failed to set NP (IPv4) mode: %s\n", strerror(errno));
- }
-
- if (ses->ipv6) {
- np.protocol = PPP_IPV6;
- np.mode = NPMODE_PASS;
+ if (ses->ctrl->type != CTRL_TYPE_IPOE) {
+ ppp = container_of(ses, typeof(*ppp), ses);
+ if (ses->ipv4) {
+ np.protocol = PPP_IP;
+ np.mode = NPMODE_PASS;
+
+ if (ioctl(ppp->unit_fd, PPPIOCSNPMODE, &np))
+ log_ppp_error("failed to set NP (IPv4) mode: %s\n", strerror(errno));
+ }
+
+ if (ses->ipv6) {
+ np.protocol = PPP_IPV6;
+ np.mode = NPMODE_PASS;
- if (ioctl(ppp->unit_fd, PPPIOCSNPMODE, &np))
- log_ppp_error("failed to set NP (IPv6) mode: %s\n", strerror(errno));
+ if (ioctl(ppp->unit_fd, PPPIOCSNPMODE, &np))
+ log_ppp_error("failed to set NP (IPv6) mode: %s\n", strerror(errno));
+ }
}
- }
#ifdef USE_BACKUP
- }
+ }
#endif
+ }
ses->ctrl->started(ses);
@@ -182,6 +184,9 @@ void __export ap_session_ifdown(struct ap_session *ses)
struct in6_ifreq ifr6;
struct ipv6db_addr_t *a;
+ if (ses->ctrl->dont_ifcfg)
+ return;
+
memset(&ifr, 0, sizeof(ifr));
strcpy(ifr.ifr_name, ses->ifname);