Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Achou.Wang
accel-ppp
提交
27b57115
A
accel-ppp
项目概览
Achou.Wang
/
accel-ppp
通知
6
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
accel-ppp
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
27b57115
编写于
7月 11, 2012
作者:
K
Kozlov Dmitry
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
ipoe: implemented unit cache
上级
db98faab
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
57 addition
and
15 deletion
+57
-15
accel-pppd/ctrl/ipoe/ipoe.c
accel-pppd/ctrl/ipoe/ipoe.c
+47
-7
accel-pppd/ctrl/ipoe/ipoe_netlink.c
accel-pppd/ctrl/ipoe/ipoe_netlink.c
+2
-6
accel-pppd/ifcfg.c
accel-pppd/ifcfg.c
+1
-2
drivers/ipoe/ipoe.c
drivers/ipoe/ipoe.c
+7
-0
未找到文件。
accel-pppd/ctrl/ipoe/ipoe.c
浏览文件 @
27b57115
...
...
@@ -46,6 +46,7 @@ static int conf_mode = 0;
static
int
conf_shared
=
1
;
//static int conf_dhcpv6;
static
int
conf_username
;
static
int
conf_unit_cache
;
#ifdef USE_LUA
static
const
char
*
conf_lua_username_func
;
...
...
@@ -71,6 +72,17 @@ struct iplink_arg
const
char
*
opt
;
};
struct
unit_cache
{
struct
list_head
entry
;
int
ifindex
;
};
static
pthread_mutex_t
uc_lock
=
PTHREAD_MUTEX_INITIALIZER
;
static
LIST_HEAD
(
uc_list
);
static
int
uc_size
;
static
mempool_t
uc_pool
;
static
void
ipoe_session_finished
(
struct
ap_session
*
s
);
static
void
ipoe_drop_sessions
(
struct
ipoe_serv
*
serv
,
struct
ipoe_session
*
skip
);
static
void
ipoe_serv_close
(
struct
triton_context_t
*
ctx
);
...
...
@@ -163,15 +175,27 @@ static void ipoe_session_start(struct ipoe_session *ses)
int
r
;
char
*
passwd
;
struct
ifreq
ifr
;
struct
unit_cache
*
uc
;
if
(
ses
->
serv
->
opt_shared
==
0
)
strncpy
(
ses
->
ses
.
ifname
,
ses
->
serv
->
ifname
,
AP_IFNAME_LEN
);
else
if
(
ses
->
ifindex
==
-
1
)
{
ses
->
ifindex
=
ipoe_nl_create
(
0
,
0
,
ses
->
dhcpv4_request
?
ses
->
serv
->
ifname
:
NULL
,
ses
->
hwaddr
);
if
(
ses
->
ifindex
==
-
1
)
{
log_ppp_error
(
"ipoe: failed to create interface
\n
"
);
ipoe_session_finished
(
&
ses
->
ses
);
return
;
pthread_mutex_lock
(
&
uc_lock
);
if
(
!
list_empty
(
&
uc_list
))
{
uc
=
list_entry
(
uc_list
.
next
,
typeof
(
*
uc
),
entry
);
ses
->
ifindex
=
uc
->
ifindex
;
list_del
(
&
uc
->
entry
);
--
uc_size
;
pthread_mutex_unlock
(
&
uc_lock
);
mempool_free
(
uc
);
}
else
{
pthread_mutex_unlock
(
&
uc_lock
);
ses
->
ifindex
=
ipoe_nl_create
(
0
,
0
,
ses
->
serv
->
opt_mode
==
MODE_L2
?
ses
->
serv
->
ifname
:
NULL
,
ses
->
hwaddr
);
if
(
ses
->
ifindex
==
-
1
)
{
log_ppp_error
(
"ipoe: failed to create interface
\n
"
);
ipoe_session_finished
(
&
ses
->
ses
);
return
;
}
}
memset
(
&
ifr
,
0
,
sizeof
(
ifr
));
...
...
@@ -296,6 +320,8 @@ static void ipoe_session_started(struct ap_session *s)
static
void
ipoe_session_free
(
struct
ipoe_session
*
ses
)
{
struct
unit_cache
*
uc
;
if
(
ses
->
timer
.
tpd
)
triton_timer_del
(
&
ses
->
timer
);
...
...
@@ -313,8 +339,17 @@ static void ipoe_session_free(struct ipoe_session *ses)
if
(
ses
->
data
)
_free
(
ses
->
data
);
if
(
ses
->
ifindex
!=
-
1
)
ipoe_nl_delete
(
ses
->
ifindex
);
if
(
ses
->
ifindex
!=
-
1
)
{
if
(
uc_size
<
conf_unit_cache
&&
ipoe_nl_modify
(
ses
->
ifindex
,
0
,
0
,
""
,
NULL
))
{
uc
=
mempool_alloc
(
uc_pool
);
uc
->
ifindex
=
ses
->
ifindex
;
pthread_mutex_lock
(
&
uc_lock
);
list_add_tail
(
&
uc
->
entry
,
&
uc_list
);
++
uc_size
;
pthread_mutex_unlock
(
&
uc_lock
);
}
else
ipoe_nl_delete
(
ses
->
ifindex
);
}
mempool_free
(
ses
);
}
...
...
@@ -1047,6 +1082,10 @@ static void load_config(void)
if
(
opt
)
conf_lease_timeout
=
atoi
(
opt
);
opt
=
conf_get_opt
(
"ipoe"
,
"unit-cache"
);
if
(
opt
)
conf_unit_cache
=
atoi
(
opt
);
opt
=
conf_get_opt
(
"ipoe"
,
"shared"
);
if
(
opt
)
conf_shared
=
atoi
(
opt
);
...
...
@@ -1086,6 +1125,7 @@ static void load_config(void)
static
void
ipoe_init
(
void
)
{
ses_pool
=
mempool_create
(
sizeof
(
struct
ipoe_session
));
uc_pool
=
mempool_create
(
sizeof
(
struct
unit_cache
));
load_config
();
...
...
accel-pppd/ctrl/ipoe/ipoe_netlink.c
浏览文件 @
27b57115
...
...
@@ -194,12 +194,8 @@ int ipoe_nl_modify(int ifindex, uint32_t peer_addr, uint32_t addr, const char *i
ghdr
->
cmd
=
IPOE_CMD_MODIFY
;
addattr32
(
nlh
,
1024
,
IPOE_ATTR_IFINDEX
,
ifindex
);
if
(
peer_addr
)
addattr32
(
nlh
,
1024
,
IPOE_ATTR_PEER_ADDR
,
peer_addr
);
if
(
addr
)
addattr32
(
nlh
,
1024
,
IPOE_ATTR_ADDR
,
addr
);
addattr32
(
nlh
,
1024
,
IPOE_ATTR_PEER_ADDR
,
peer_addr
);
addattr32
(
nlh
,
1024
,
IPOE_ATTR_ADDR
,
addr
);
if
(
hwaddr
)
{
memcpy
(
u
.
hwaddr
,
hwaddr
,
6
);
...
...
accel-pppd/ifcfg.c
浏览文件 @
27b57115
...
...
@@ -185,8 +185,7 @@ void __export ap_session_ifdown(struct ap_session *ses)
memset
(
&
ifr
,
0
,
sizeof
(
ifr
));
strcpy
(
ifr
.
ifr_name
,
ses
->
ifname
);
if
(
ses
->
ctrl
->
type
!=
CTRL_TYPE_IPOE
)
ioctl
(
sock_fd
,
SIOCSIFFLAGS
,
&
ifr
);
ioctl
(
sock_fd
,
SIOCSIFFLAGS
,
&
ifr
);
if
(
ses
->
ipv4
)
{
memset
(
&
addr
,
0
,
sizeof
(
addr
));
...
...
drivers/ipoe/ipoe.c
浏览文件 @
27b57115
...
...
@@ -1202,6 +1202,13 @@ static int ipoe_nl_cmd_modify(struct sk_buff *skb, struct genl_info *info)
old_dev
=
ses
->
link_dev
;
ses
->
link_dev
=
link_dev
;
if
(
link_dev
)
{
ses
->
dev
->
features
=
link_dev
->
features
;
memcpy
(
dev
->
dev_addr
,
link_dev
->
dev_addr
,
ETH_ALEN
);
memcpy
(
dev
->
broadcast
,
link_dev
->
broadcast
,
ETH_ALEN
);
}
if
(
old_dev
)
dev_put
(
old_dev
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录