Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
Kernel
提交
10b0a773
K
Kernel
项目概览
openeuler
/
Kernel
1 年多 前同步成功
通知
8
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
K
Kernel
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
10b0a773
编写于
7月 12, 2012
作者:
D
David S. Miller
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'for-davem' of
git://gitorious.org/linux-can/linux-can-next
上级
d3bd3a5e
5d91efa8
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
33 addition
and
57 deletion
+33
-57
net/can/gw.c
net/can/gw.c
+33
-57
未找到文件。
net/can/gw.c
浏览文件 @
10b0a773
...
@@ -444,11 +444,14 @@ static int cgw_notifier(struct notifier_block *nb,
...
@@ -444,11 +444,14 @@ static int cgw_notifier(struct notifier_block *nb,
return
NOTIFY_DONE
;
return
NOTIFY_DONE
;
}
}
static
int
cgw_put_job
(
struct
sk_buff
*
skb
,
struct
cgw_job
*
gwj
)
static
int
cgw_put_job
(
struct
sk_buff
*
skb
,
struct
cgw_job
*
gwj
,
int
type
,
u32
pid
,
u32
seq
,
int
flags
)
{
{
struct
cgw_frame_mod
mb
;
struct
cgw_frame_mod
mb
;
struct
rtcanmsg
*
rtcan
;
struct
rtcanmsg
*
rtcan
;
struct
nlmsghdr
*
nlh
=
nlmsg_put
(
skb
,
0
,
0
,
0
,
sizeof
(
*
rtcan
),
0
);
struct
nlmsghdr
*
nlh
;
nlh
=
nlmsg_put
(
skb
,
pid
,
seq
,
type
,
sizeof
(
*
rtcan
),
flags
);
if
(
!
nlh
)
if
(
!
nlh
)
return
-
EMSGSIZE
;
return
-
EMSGSIZE
;
...
@@ -462,15 +465,11 @@ static int cgw_put_job(struct sk_buff *skb, struct cgw_job *gwj)
...
@@ -462,15 +465,11 @@ static int cgw_put_job(struct sk_buff *skb, struct cgw_job *gwj)
if
(
gwj
->
handled_frames
)
{
if
(
gwj
->
handled_frames
)
{
if
(
nla_put_u32
(
skb
,
CGW_HANDLED
,
gwj
->
handled_frames
)
<
0
)
if
(
nla_put_u32
(
skb
,
CGW_HANDLED
,
gwj
->
handled_frames
)
<
0
)
goto
cancel
;
goto
cancel
;
else
nlh
->
nlmsg_len
+=
NLA_HDRLEN
+
NLA_ALIGN
(
sizeof
(
u32
));
}
}
if
(
gwj
->
dropped_frames
)
{
if
(
gwj
->
dropped_frames
)
{
if
(
nla_put_u32
(
skb
,
CGW_DROPPED
,
gwj
->
dropped_frames
)
<
0
)
if
(
nla_put_u32
(
skb
,
CGW_DROPPED
,
gwj
->
dropped_frames
)
<
0
)
goto
cancel
;
goto
cancel
;
else
nlh
->
nlmsg_len
+=
NLA_HDRLEN
+
NLA_ALIGN
(
sizeof
(
u32
));
}
}
/* check non default settings of attributes */
/* check non default settings of attributes */
...
@@ -480,8 +479,6 @@ static int cgw_put_job(struct sk_buff *skb, struct cgw_job *gwj)
...
@@ -480,8 +479,6 @@ static int cgw_put_job(struct sk_buff *skb, struct cgw_job *gwj)
mb
.
modtype
=
gwj
->
mod
.
modtype
.
and
;
mb
.
modtype
=
gwj
->
mod
.
modtype
.
and
;
if
(
nla_put
(
skb
,
CGW_MOD_AND
,
sizeof
(
mb
),
&
mb
)
<
0
)
if
(
nla_put
(
skb
,
CGW_MOD_AND
,
sizeof
(
mb
),
&
mb
)
<
0
)
goto
cancel
;
goto
cancel
;
else
nlh
->
nlmsg_len
+=
NLA_HDRLEN
+
NLA_ALIGN
(
sizeof
(
mb
));
}
}
if
(
gwj
->
mod
.
modtype
.
or
)
{
if
(
gwj
->
mod
.
modtype
.
or
)
{
...
@@ -489,8 +486,6 @@ static int cgw_put_job(struct sk_buff *skb, struct cgw_job *gwj)
...
@@ -489,8 +486,6 @@ static int cgw_put_job(struct sk_buff *skb, struct cgw_job *gwj)
mb
.
modtype
=
gwj
->
mod
.
modtype
.
or
;
mb
.
modtype
=
gwj
->
mod
.
modtype
.
or
;
if
(
nla_put
(
skb
,
CGW_MOD_OR
,
sizeof
(
mb
),
&
mb
)
<
0
)
if
(
nla_put
(
skb
,
CGW_MOD_OR
,
sizeof
(
mb
),
&
mb
)
<
0
)
goto
cancel
;
goto
cancel
;
else
nlh
->
nlmsg_len
+=
NLA_HDRLEN
+
NLA_ALIGN
(
sizeof
(
mb
));
}
}
if
(
gwj
->
mod
.
modtype
.
xor
)
{
if
(
gwj
->
mod
.
modtype
.
xor
)
{
...
@@ -498,8 +493,6 @@ static int cgw_put_job(struct sk_buff *skb, struct cgw_job *gwj)
...
@@ -498,8 +493,6 @@ static int cgw_put_job(struct sk_buff *skb, struct cgw_job *gwj)
mb
.
modtype
=
gwj
->
mod
.
modtype
.
xor
;
mb
.
modtype
=
gwj
->
mod
.
modtype
.
xor
;
if
(
nla_put
(
skb
,
CGW_MOD_XOR
,
sizeof
(
mb
),
&
mb
)
<
0
)
if
(
nla_put
(
skb
,
CGW_MOD_XOR
,
sizeof
(
mb
),
&
mb
)
<
0
)
goto
cancel
;
goto
cancel
;
else
nlh
->
nlmsg_len
+=
NLA_HDRLEN
+
NLA_ALIGN
(
sizeof
(
mb
));
}
}
if
(
gwj
->
mod
.
modtype
.
set
)
{
if
(
gwj
->
mod
.
modtype
.
set
)
{
...
@@ -507,26 +500,18 @@ static int cgw_put_job(struct sk_buff *skb, struct cgw_job *gwj)
...
@@ -507,26 +500,18 @@ static int cgw_put_job(struct sk_buff *skb, struct cgw_job *gwj)
mb
.
modtype
=
gwj
->
mod
.
modtype
.
set
;
mb
.
modtype
=
gwj
->
mod
.
modtype
.
set
;
if
(
nla_put
(
skb
,
CGW_MOD_SET
,
sizeof
(
mb
),
&
mb
)
<
0
)
if
(
nla_put
(
skb
,
CGW_MOD_SET
,
sizeof
(
mb
),
&
mb
)
<
0
)
goto
cancel
;
goto
cancel
;
else
nlh
->
nlmsg_len
+=
NLA_HDRLEN
+
NLA_ALIGN
(
sizeof
(
mb
));
}
}
if
(
gwj
->
mod
.
csumfunc
.
crc8
)
{
if
(
gwj
->
mod
.
csumfunc
.
crc8
)
{
if
(
nla_put
(
skb
,
CGW_CS_CRC8
,
CGW_CS_CRC8_LEN
,
if
(
nla_put
(
skb
,
CGW_CS_CRC8
,
CGW_CS_CRC8_LEN
,
&
gwj
->
mod
.
csum
.
crc8
)
<
0
)
&
gwj
->
mod
.
csum
.
crc8
)
<
0
)
goto
cancel
;
goto
cancel
;
else
nlh
->
nlmsg_len
+=
NLA_HDRLEN
+
\
NLA_ALIGN
(
CGW_CS_CRC8_LEN
);
}
}
if
(
gwj
->
mod
.
csumfunc
.
xor
)
{
if
(
gwj
->
mod
.
csumfunc
.
xor
)
{
if
(
nla_put
(
skb
,
CGW_CS_XOR
,
CGW_CS_XOR_LEN
,
if
(
nla_put
(
skb
,
CGW_CS_XOR
,
CGW_CS_XOR_LEN
,
&
gwj
->
mod
.
csum
.
xor
)
<
0
)
&
gwj
->
mod
.
csum
.
xor
)
<
0
)
goto
cancel
;
goto
cancel
;
else
nlh
->
nlmsg_len
+=
NLA_HDRLEN
+
\
NLA_ALIGN
(
CGW_CS_XOR_LEN
);
}
}
if
(
gwj
->
gwtype
==
CGW_TYPE_CAN_CAN
)
{
if
(
gwj
->
gwtype
==
CGW_TYPE_CAN_CAN
)
{
...
@@ -535,23 +520,16 @@ static int cgw_put_job(struct sk_buff *skb, struct cgw_job *gwj)
...
@@ -535,23 +520,16 @@ static int cgw_put_job(struct sk_buff *skb, struct cgw_job *gwj)
if
(
nla_put
(
skb
,
CGW_FILTER
,
sizeof
(
struct
can_filter
),
if
(
nla_put
(
skb
,
CGW_FILTER
,
sizeof
(
struct
can_filter
),
&
gwj
->
ccgw
.
filter
)
<
0
)
&
gwj
->
ccgw
.
filter
)
<
0
)
goto
cancel
;
goto
cancel
;
else
nlh
->
nlmsg_len
+=
NLA_HDRLEN
+
NLA_ALIGN
(
sizeof
(
struct
can_filter
));
}
}
if
(
nla_put_u32
(
skb
,
CGW_SRC_IF
,
gwj
->
ccgw
.
src_idx
)
<
0
)
if
(
nla_put_u32
(
skb
,
CGW_SRC_IF
,
gwj
->
ccgw
.
src_idx
)
<
0
)
goto
cancel
;
goto
cancel
;
else
nlh
->
nlmsg_len
+=
NLA_HDRLEN
+
NLA_ALIGN
(
sizeof
(
u32
));
if
(
nla_put_u32
(
skb
,
CGW_DST_IF
,
gwj
->
ccgw
.
dst_idx
)
<
0
)
if
(
nla_put_u32
(
skb
,
CGW_DST_IF
,
gwj
->
ccgw
.
dst_idx
)
<
0
)
goto
cancel
;
goto
cancel
;
else
nlh
->
nlmsg_len
+=
NLA_HDRLEN
+
NLA_ALIGN
(
sizeof
(
u32
));
}
}
return
skb
->
len
;
return
nlmsg_end
(
skb
,
nlh
)
;
cancel:
cancel:
nlmsg_cancel
(
skb
,
nlh
);
nlmsg_cancel
(
skb
,
nlh
);
...
@@ -571,7 +549,8 @@ static int cgw_dump_jobs(struct sk_buff *skb, struct netlink_callback *cb)
...
@@ -571,7 +549,8 @@ static int cgw_dump_jobs(struct sk_buff *skb, struct netlink_callback *cb)
if
(
idx
<
s_idx
)
if
(
idx
<
s_idx
)
goto
cont
;
goto
cont
;
if
(
cgw_put_job
(
skb
,
gwj
)
<
0
)
if
(
cgw_put_job
(
skb
,
gwj
,
RTM_NEWROUTE
,
NETLINK_CB
(
cb
->
skb
).
pid
,
cb
->
nlh
->
nlmsg_seq
,
NLM_F_MULTI
)
<
0
)
break
;
break
;
cont:
cont:
idx
++
;
idx
++
;
...
@@ -583,6 +562,18 @@ static int cgw_dump_jobs(struct sk_buff *skb, struct netlink_callback *cb)
...
@@ -583,6 +562,18 @@ static int cgw_dump_jobs(struct sk_buff *skb, struct netlink_callback *cb)
return
skb
->
len
;
return
skb
->
len
;
}
}
static
const
struct
nla_policy
cgw_policy
[
CGW_MAX
+
1
]
=
{
[
CGW_MOD_AND
]
=
{
.
len
=
sizeof
(
struct
cgw_frame_mod
)
},
[
CGW_MOD_OR
]
=
{
.
len
=
sizeof
(
struct
cgw_frame_mod
)
},
[
CGW_MOD_XOR
]
=
{
.
len
=
sizeof
(
struct
cgw_frame_mod
)
},
[
CGW_MOD_SET
]
=
{
.
len
=
sizeof
(
struct
cgw_frame_mod
)
},
[
CGW_CS_XOR
]
=
{
.
len
=
sizeof
(
struct
cgw_csum_xor
)
},
[
CGW_CS_CRC8
]
=
{
.
len
=
sizeof
(
struct
cgw_csum_crc8
)
},
[
CGW_SRC_IF
]
=
{
.
type
=
NLA_U32
},
[
CGW_DST_IF
]
=
{
.
type
=
NLA_U32
},
[
CGW_FILTER
]
=
{
.
len
=
sizeof
(
struct
can_filter
)
},
};
/* check for common and gwtype specific attributes */
/* check for common and gwtype specific attributes */
static
int
cgw_parse_attr
(
struct
nlmsghdr
*
nlh
,
struct
cf_mod
*
mod
,
static
int
cgw_parse_attr
(
struct
nlmsghdr
*
nlh
,
struct
cf_mod
*
mod
,
u8
gwtype
,
void
*
gwtypeattr
)
u8
gwtype
,
void
*
gwtypeattr
)
...
@@ -595,14 +586,14 @@ static int cgw_parse_attr(struct nlmsghdr *nlh, struct cf_mod *mod,
...
@@ -595,14 +586,14 @@ static int cgw_parse_attr(struct nlmsghdr *nlh, struct cf_mod *mod,
/* initialize modification & checksum data space */
/* initialize modification & checksum data space */
memset
(
mod
,
0
,
sizeof
(
*
mod
));
memset
(
mod
,
0
,
sizeof
(
*
mod
));
err
=
nlmsg_parse
(
nlh
,
sizeof
(
struct
rtcanmsg
),
tb
,
CGW_MAX
,
NULL
);
err
=
nlmsg_parse
(
nlh
,
sizeof
(
struct
rtcanmsg
),
tb
,
CGW_MAX
,
cgw_policy
);
if
(
err
<
0
)
if
(
err
<
0
)
return
err
;
return
err
;
/* check for AND/OR/XOR/SET modifications */
/* check for AND/OR/XOR/SET modifications */
if
(
tb
[
CGW_MOD_AND
]
&&
if
(
tb
[
CGW_MOD_AND
])
{
nla_len
(
tb
[
CGW_MOD_AND
])
==
CGW_MODATTR_LEN
)
{
nla_memcpy
(
&
mb
,
tb
[
CGW_MOD_AND
],
CGW_MODATTR_LEN
);
nla_memcpy
(
&
mb
,
tb
[
CGW_MOD_AND
],
CGW_MODATTR_LEN
);
canframecpy
(
&
mod
->
modframe
.
and
,
&
mb
.
cf
);
canframecpy
(
&
mod
->
modframe
.
and
,
&
mb
.
cf
);
...
@@ -618,8 +609,7 @@ static int cgw_parse_attr(struct nlmsghdr *nlh, struct cf_mod *mod,
...
@@ -618,8 +609,7 @@ static int cgw_parse_attr(struct nlmsghdr *nlh, struct cf_mod *mod,
mod
->
modfunc
[
modidx
++
]
=
mod_and_data
;
mod
->
modfunc
[
modidx
++
]
=
mod_and_data
;
}
}
if
(
tb
[
CGW_MOD_OR
]
&&
if
(
tb
[
CGW_MOD_OR
])
{
nla_len
(
tb
[
CGW_MOD_OR
])
==
CGW_MODATTR_LEN
)
{
nla_memcpy
(
&
mb
,
tb
[
CGW_MOD_OR
],
CGW_MODATTR_LEN
);
nla_memcpy
(
&
mb
,
tb
[
CGW_MOD_OR
],
CGW_MODATTR_LEN
);
canframecpy
(
&
mod
->
modframe
.
or
,
&
mb
.
cf
);
canframecpy
(
&
mod
->
modframe
.
or
,
&
mb
.
cf
);
...
@@ -635,8 +625,7 @@ static int cgw_parse_attr(struct nlmsghdr *nlh, struct cf_mod *mod,
...
@@ -635,8 +625,7 @@ static int cgw_parse_attr(struct nlmsghdr *nlh, struct cf_mod *mod,
mod
->
modfunc
[
modidx
++
]
=
mod_or_data
;
mod
->
modfunc
[
modidx
++
]
=
mod_or_data
;
}
}
if
(
tb
[
CGW_MOD_XOR
]
&&
if
(
tb
[
CGW_MOD_XOR
])
{
nla_len
(
tb
[
CGW_MOD_XOR
])
==
CGW_MODATTR_LEN
)
{
nla_memcpy
(
&
mb
,
tb
[
CGW_MOD_XOR
],
CGW_MODATTR_LEN
);
nla_memcpy
(
&
mb
,
tb
[
CGW_MOD_XOR
],
CGW_MODATTR_LEN
);
canframecpy
(
&
mod
->
modframe
.
xor
,
&
mb
.
cf
);
canframecpy
(
&
mod
->
modframe
.
xor
,
&
mb
.
cf
);
...
@@ -652,8 +641,7 @@ static int cgw_parse_attr(struct nlmsghdr *nlh, struct cf_mod *mod,
...
@@ -652,8 +641,7 @@ static int cgw_parse_attr(struct nlmsghdr *nlh, struct cf_mod *mod,
mod
->
modfunc
[
modidx
++
]
=
mod_xor_data
;
mod
->
modfunc
[
modidx
++
]
=
mod_xor_data
;
}
}
if
(
tb
[
CGW_MOD_SET
]
&&
if
(
tb
[
CGW_MOD_SET
])
{
nla_len
(
tb
[
CGW_MOD_SET
])
==
CGW_MODATTR_LEN
)
{
nla_memcpy
(
&
mb
,
tb
[
CGW_MOD_SET
],
CGW_MODATTR_LEN
);
nla_memcpy
(
&
mb
,
tb
[
CGW_MOD_SET
],
CGW_MODATTR_LEN
);
canframecpy
(
&
mod
->
modframe
.
set
,
&
mb
.
cf
);
canframecpy
(
&
mod
->
modframe
.
set
,
&
mb
.
cf
);
...
@@ -672,11 +660,8 @@ static int cgw_parse_attr(struct nlmsghdr *nlh, struct cf_mod *mod,
...
@@ -672,11 +660,8 @@ static int cgw_parse_attr(struct nlmsghdr *nlh, struct cf_mod *mod,
/* check for checksum operations after CAN frame modifications */
/* check for checksum operations after CAN frame modifications */
if
(
modidx
)
{
if
(
modidx
)
{
if
(
tb
[
CGW_CS_CRC8
]
&&
if
(
tb
[
CGW_CS_CRC8
])
{
nla_len
(
tb
[
CGW_CS_CRC8
])
==
CGW_CS_CRC8_LEN
)
{
struct
cgw_csum_crc8
*
c
=
nla_data
(
tb
[
CGW_CS_CRC8
]);
struct
cgw_csum_crc8
*
c
=
(
struct
cgw_csum_crc8
*
)
\
nla_data
(
tb
[
CGW_CS_CRC8
]);
err
=
cgw_chk_csum_parms
(
c
->
from_idx
,
c
->
to_idx
,
err
=
cgw_chk_csum_parms
(
c
->
from_idx
,
c
->
to_idx
,
c
->
result_idx
);
c
->
result_idx
);
...
@@ -699,11 +684,8 @@ static int cgw_parse_attr(struct nlmsghdr *nlh, struct cf_mod *mod,
...
@@ -699,11 +684,8 @@ static int cgw_parse_attr(struct nlmsghdr *nlh, struct cf_mod *mod,
mod
->
csumfunc
.
crc8
=
cgw_csum_crc8_neg
;
mod
->
csumfunc
.
crc8
=
cgw_csum_crc8_neg
;
}
}
if
(
tb
[
CGW_CS_XOR
]
&&
if
(
tb
[
CGW_CS_XOR
])
{
nla_len
(
tb
[
CGW_CS_XOR
])
==
CGW_CS_XOR_LEN
)
{
struct
cgw_csum_xor
*
c
=
nla_data
(
tb
[
CGW_CS_XOR
]);
struct
cgw_csum_xor
*
c
=
(
struct
cgw_csum_xor
*
)
\
nla_data
(
tb
[
CGW_CS_XOR
]);
err
=
cgw_chk_csum_parms
(
c
->
from_idx
,
c
->
to_idx
,
err
=
cgw_chk_csum_parms
(
c
->
from_idx
,
c
->
to_idx
,
c
->
result_idx
);
c
->
result_idx
);
...
@@ -735,8 +717,7 @@ static int cgw_parse_attr(struct nlmsghdr *nlh, struct cf_mod *mod,
...
@@ -735,8 +717,7 @@ static int cgw_parse_attr(struct nlmsghdr *nlh, struct cf_mod *mod,
memset
(
ccgw
,
0
,
sizeof
(
*
ccgw
));
memset
(
ccgw
,
0
,
sizeof
(
*
ccgw
));
/* check for can_filter in attributes */
/* check for can_filter in attributes */
if
(
tb
[
CGW_FILTER
]
&&
if
(
tb
[
CGW_FILTER
])
nla_len
(
tb
[
CGW_FILTER
])
==
sizeof
(
struct
can_filter
))
nla_memcpy
(
&
ccgw
->
filter
,
tb
[
CGW_FILTER
],
nla_memcpy
(
&
ccgw
->
filter
,
tb
[
CGW_FILTER
],
sizeof
(
struct
can_filter
));
sizeof
(
struct
can_filter
));
...
@@ -746,13 +727,8 @@ static int cgw_parse_attr(struct nlmsghdr *nlh, struct cf_mod *mod,
...
@@ -746,13 +727,8 @@ static int cgw_parse_attr(struct nlmsghdr *nlh, struct cf_mod *mod,
if
(
!
tb
[
CGW_SRC_IF
]
||
!
tb
[
CGW_DST_IF
])
if
(
!
tb
[
CGW_SRC_IF
]
||
!
tb
[
CGW_DST_IF
])
return
err
;
return
err
;
if
(
nla_len
(
tb
[
CGW_SRC_IF
])
==
sizeof
(
u32
))
ccgw
->
src_idx
=
nla_get_u32
(
tb
[
CGW_SRC_IF
]);
nla_memcpy
(
&
ccgw
->
src_idx
,
tb
[
CGW_SRC_IF
],
ccgw
->
dst_idx
=
nla_get_u32
(
tb
[
CGW_DST_IF
]);
sizeof
(
u32
));
if
(
nla_len
(
tb
[
CGW_DST_IF
])
==
sizeof
(
u32
))
nla_memcpy
(
&
ccgw
->
dst_idx
,
tb
[
CGW_DST_IF
],
sizeof
(
u32
));
/* both indices set to 0 for flushing all routing entries */
/* both indices set to 0 for flushing all routing entries */
if
(
!
ccgw
->
src_idx
&&
!
ccgw
->
dst_idx
)
if
(
!
ccgw
->
src_idx
&&
!
ccgw
->
dst_idx
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录