Skip to contentSkip to conversation

problem with function vlan_get_protocol()

DISCUSSION jiangtao.jit 2 participants 3 messages Jul 17, 2011

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hi,all

in file inclue/linux/if_vlan.h

there is a statement in function vlan_get_protocol()

	if (likely(protop))
		protocol = *protop;

do we need an else branch on pointer protop failed ? through the else is unlikely

	if (likely(protop))
		protocol = *protop;
    else
		protocol = proto;

is it necessary ?

thanks

2011-07-17
jiangtao.jit

#1 lore raw

jiangtao.jit <[email protected]> :
[...]

Quoted 8 lines

do we need an else branch on pointer protop failed ? through the else is unlikely

	if (likely(protop))
		protocol = *protop;
    else
		protocol = proto;

is it necessary ?

The else branch signals that skb_header_pointer uncloaked a really tiny ethernet frame : the content of proto is not even initialized (stack allocation), whence irrelevant. In such circumstances the default initialization value of protocol (0) does not seem too bad.

Signature · 1 line
Ueimor
#2 lore raw
In reply to jiangtao.jit

Thanks a lot Francois
thank you for your explanation

--
jiangtao

发件人: Francois Romieu
发送时间: 2011-07-17 15:49:00
收件人: jiangtao.jit
抄送: netdev
主题: Re: problem with function vlan_get_protocol()

jiangtao.jit <[email protected]> :
[...]

Quoted 8 lines

do we need an else branch on pointer protop failed ? through the else is unlikely

if (likely(protop))
protocol = *protop;
else
protocol = proto;

is it necessary ?

The else branch signals that skb_header_pointer uncloaked a really tiny ethernet frame : the content of proto is not even initialized (stack allocation), whence irrelevant. In such circumstances the default initialization value of protocol (0) does not seem too bad.

Signature · 1 line
Ueimor