Skip to content

Commit

Permalink
ipoe: implemented ipv6 in shared mode
Browse files Browse the repository at this point in the history
  • Loading branch information
xebd committed Jan 5, 2018
1 parent bff66de commit 16e4de5
Show file tree
Hide file tree
Showing 3 changed files with 171 additions and 59 deletions.
40 changes: 40 additions & 0 deletions accel-pppd/ctrl/ipoe/ipoe.c
Expand Up @@ -214,6 +214,7 @@ static void ipoe_session_create_auto(struct ipoe_serv *serv);
static void ipoe_serv_timeout(struct triton_timer_t *t);
static struct ipoe_session *ipoe_session_create_up(struct ipoe_serv *serv, struct ethhdr *eth, struct iphdr *iph, struct _arphdr *arph);
static void __terminate(struct ap_session *ses);
static void ipoe_ipv6_disable(struct ipoe_serv *serv);

static void ipoe_ctx_switch(struct triton_context_t *ctx, void *arg)
{
Expand Down Expand Up @@ -2389,6 +2390,9 @@ static void ipoe_serv_release(struct ipoe_serv *serv)
if (serv->arp)
arpd_stop(serv->arp);

if (serv->opt_ipv6)
ipoe_ipv6_disable(serv);

while (!list_empty(&serv->disc_list)) {
struct disc_item *d = list_entry(serv->disc_list.next, typeof(*d), entry);
list_del(&d->entry);
Expand Down Expand Up @@ -2705,6 +2709,39 @@ static void ipoe_serv_timeout(struct triton_timer_t *t)
ipoe_serv_release(serv);
}

static void ipoe_ipv6_enable(struct ipoe_serv *serv)
{
struct ifreq ifr;

strcpy(ifr.ifr_name, serv->ifname);

ifr.ifr_hwaddr.sa_family = AF_UNSPEC;
ifr.ifr_hwaddr.sa_data[0] = 0x33;
ifr.ifr_hwaddr.sa_data[1] = 0x33;
*(uint32_t *)(ifr.ifr_hwaddr.sa_data + 2) = htonl(0x02);
ioctl(sock_fd, SIOCADDMULTI, &ifr);

*(uint32_t *)(ifr.ifr_hwaddr.sa_data + 2) = htonl(0x010002);
ioctl(sock_fd, SIOCADDMULTI, &ifr);
}

static void ipoe_ipv6_disable(struct ipoe_serv *serv)
{
struct ifreq ifr;

strcpy(ifr.ifr_name, serv->ifname);

ifr.ifr_hwaddr.sa_family = AF_UNSPEC;
ifr.ifr_hwaddr.sa_data[0] = 0x33;
ifr.ifr_hwaddr.sa_data[1] = 0x33;
*(uint32_t *)(ifr.ifr_hwaddr.sa_data + 2) = htonl(0x02);
ioctl(sock_fd, SIOCDELMULTI, &ifr);

*(uint32_t *)(ifr.ifr_hwaddr.sa_data + 2) = htonl(0x010002);
ioctl(sock_fd, SIOCDELMULTI, &ifr);
}


static void add_interface(const char *ifname, int ifindex, const char *opt, int parent_ifindex, int vid, int vlan_mon)
{
char *str0 = NULL, *str, *ptr1, *ptr2;
Expand Down Expand Up @@ -3012,6 +3049,9 @@ static void add_interface(const char *ifname, int ifindex, const char *opt, int
if (serv->opt_arp)
serv->arp = arpd_start(serv);

if (serv->opt_ipv6 && serv->opt_shared)
ipoe_ipv6_enable(serv);

if (vlan_mon) {
serv->vlan_mon = 1;
set_vlan_timeout(serv);
Expand Down
2 changes: 2 additions & 0 deletions accel-pppd/ctrl/ipoe/ipoe.h
Expand Up @@ -126,6 +126,8 @@ struct ipoe_session_info {
uint32_t peer_addr;
};

int ipoe_ipv6_nd_start(struct ipoe_serv *serv);

#ifdef USE_LUA
char *ipoe_lua_get_username(struct ipoe_session *, const char *func);
int ipoe_lua_make_vlan_name(const char *func, const char *parent, int svid, int cvid, char *name);
Expand Down

0 comments on commit 16e4de5

Please sign in to comment.