summaryrefslogtreecommitdiff
path: root/accel-pppd/ctrl/ipoe/ipoe.c
diff options
context:
space:
mode:
authorDmitry Kozlov <xeb@mail.ru>2015-11-21 12:34:02 +0300
committerDmitry Kozlov <xeb@mail.ru>2015-11-21 12:34:02 +0300
commit9190fe47e0ce57e8f0b3360f2fe0404169b44263 (patch)
treef774de35c1895fa6b4a9b20ac65930d7675c23bc /accel-pppd/ctrl/ipoe/ipoe.c
parentdecb3de44c59f789e49250c4d2791e4219078b54 (diff)
downloadaccel-ppp-9190fe47e0ce57e8f0b3360f2fe0404169b44263.tar.gz
accel-ppp-9190fe47e0ce57e8f0b3360f2fe0404169b44263.zip
split ipoe driver to ipoe and vlan_mon
introduced new module "vlan-mon"
Diffstat (limited to 'accel-pppd/ctrl/ipoe/ipoe.c')
-rw-r--r--accel-pppd/ctrl/ipoe/ipoe.c66
1 files changed, 19 insertions, 47 deletions
diff --git a/accel-pppd/ctrl/ipoe/ipoe.c b/accel-pppd/ctrl/ipoe/ipoe.c
index 594df29e..d77da31f 100644
--- a/accel-pppd/ctrl/ipoe/ipoe.c
+++ b/accel-pppd/ctrl/ipoe/ipoe.c
@@ -33,6 +33,7 @@
#include "ipset.h"
#include "connlimit.h"
+#include "vlan_mon.h"
#include "ipoe.h"
@@ -2082,7 +2083,7 @@ static void ipoe_serv_release(struct ipoe_serv *serv)
if (serv->vid) {
log_info2("ipoe: remove vlan %s\n", serv->ifname);
iplink_vlan_del(serv->ifindex);
- ipoe_nl_add_vlan_mon_vid(serv->parent_ifindex, serv->vid);
+ vlan_mon_add_vid(serv->parent_ifindex, ETH_P_IP, serv->vid);
}
triton_context_unregister(&serv->ctx);
@@ -2205,43 +2206,7 @@ static int get_offer_delay()
return 0;
}
-static int make_vlan_name(const char *parent, int svid, int cvid, char *name)
-{
- char *ptr1 = name, *endptr = name + IFNAMSIZ;
- const char *ptr2 = conf_vlan_name;
- char svid_str[5], cvid_str[5], *ptr3;
-
- sprintf(svid_str, "%i", svid);
- sprintf(cvid_str, "%i", cvid);
-
- while (ptr1 < endptr && *ptr2) {
- if (ptr2[0] == '%' && ptr2[1] == 'I') {
- while (ptr1 < endptr && *parent)
- *ptr1++ = *parent++;
- ptr2 += 2;
- } else if (ptr2[0] == '%' && ptr2[1] == 'N') {
- ptr3 = cvid_str;
- while (ptr1 < endptr && *ptr3)
- *ptr1++ = *ptr3++;
- ptr2 += 2;
- } else if (ptr2[0] == '%' && ptr2[1] == 'P') {
- ptr3 = svid_str;
- while (ptr1 < endptr && *ptr3)
- *ptr1++ = *ptr3++;
- ptr2 += 2;
- } else
- *ptr1++ = *ptr2++;
- }
-
- if (ptr1 == endptr)
- return 1;
-
- *ptr1 = 0;
-
- return 0;
-}
-
-void ipoe_vlan_notify(int ifindex, int vid)
+void ipoe_vlan_mon_notify(int ifindex, int vid)
{
struct conf_sect_t *sect = conf_get_section("ipoe");
struct conf_option_t *opt;
@@ -2266,20 +2231,18 @@ void ipoe_vlan_notify(int ifindex, int vid)
svid = iplink_vlan_get_vid(ifindex);
- if (make_vlan_name(ifr.ifr_name, svid, vid, ifname)) {
+ if (make_vlan_name(conf_vlan_name, ifr.ifr_name, svid, vid, ifname)) {
log_error("ipoe: vlan-mon: %s.%i: interface name is too long\n", ifr.ifr_name, vid);
return;
}
- log_info2("ipoe: create vlan %s parent %s\n", ifname, ifr.ifr_name);
-
strcpy(ifr.ifr_name, ifname);
len = strlen(ifr.ifr_name);
- if (iplink_vlan_add(ifr.ifr_name, ifindex, vid)) {
- log_warn("ipoe: vlan-mon: %s: failed to add vlan\n", ifr.ifr_name);
+ if (iplink_vlan_add(ifr.ifr_name, ifindex, vid))
return;
- }
+
+ log_info2("ipoe: create vlan %s parent %s\n", ifname, ifr.ifr_name);
ioctl(sock_fd, SIOCGIFFLAGS, &ifr, sizeof(ifr));
ifr.ifr_flags |= IFF_UP;
@@ -3012,7 +2975,7 @@ static void add_vlan_mon(const char *opt, long *mask)
mask1[serv->vid / (8*sizeof(long))] |= 1lu << (serv->vid % (8*sizeof(long)));
}
- ipoe_nl_add_vlan_mon(ifindex, mask1, sizeof(mask1));
+ vlan_mon_add(ifindex, ETH_P_IP, mask1, sizeof(mask1));
}
static int __load_vlan_mon_re(int index, int flags, const char *name, struct iplink_arg *arg)
@@ -3041,7 +3004,7 @@ static int __load_vlan_mon_re(int index, int flags, const char *name, struct ipl
mask1[serv->vid / (8*sizeof(long))] |= 1lu << (serv->vid % (8*sizeof(long)));
}
- ipoe_nl_add_vlan_mon(index, mask1, sizeof(mask1));
+ vlan_mon_add(index, ETH_P_IP, mask1, sizeof(mask1));
return 0;
}
@@ -3083,8 +3046,17 @@ static void load_vlan_mon(struct conf_sect_t *sect)
{
struct conf_option_t *opt;
long mask[4096/8/sizeof(long)];
+ static int registered = 0;
+
+ if (!triton_module_loaded("vlan-mon"))
+ return;
+
+ if (!registered) {
+ vlan_mon_register_proto(ETH_P_IP, ipoe_vlan_mon_notify);
+ registered = 1;
+ }
- ipoe_nl_del_vlan_mon(-1);
+ vlan_mon_del(-1, ETH_P_IP);
list_for_each_entry(opt, &sect->items, entry) {
if (strcmp(opt->name, "vlan-mon"))