Skip to content

Commit b79a80b

Browse files
Xie Hedavem330
authored andcommitted
net/packet: Fix a comment about mac_header
1. Change all "dev->hard_header" to "dev->header_ops" 2. On receiving incoming frames when header_ops == NULL: The comment only says what is wrong, but doesn't say what is right. This patch changes the comment to make it clear what is right. 3. On transmitting and receiving outgoing frames when header_ops == NULL: The comment explains that the LL header will be later added by the driver. However, I think it's better to simply say that the LL header is invisible to us. This phrasing is better from a software engineering perspective, because this makes it clear that what happens in the driver should be hidden from us and we should not care about what happens internally in the driver. 4. On resuming the LL header (for RAW frames) when header_ops == NULL: The comment says we are "unlikely" to restore the LL header. However, we should say that we are "unable" to restore it. It's not possible (rather than not likely) to restore it, because: 1) There is no way for us to restore because the LL header internally processed by the driver should be invisible to us. 2) In function packet_rcv and tpacket_rcv, the code only tries to restore the LL header when header_ops != NULL. Cc: Willem de Bruijn <[email protected]> Signed-off-by: Xie He <[email protected]> Acked-by: Willem de Bruijn <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 31660a9 commit b79a80b

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

net/packet/af_packet.c

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -108,36 +108,37 @@
108108
On receive:
109109
-----------
110110
111-
Incoming, dev->hard_header!=NULL
111+
Incoming, dev->header_ops != NULL
112112
mac_header -> ll header
113113
data -> data
114114
115-
Outgoing, dev->hard_header!=NULL
115+
Outgoing, dev->header_ops != NULL
116116
mac_header -> ll header
117117
data -> ll header
118118
119-
Incoming, dev->hard_header==NULL
120-
mac_header -> UNKNOWN position. It is very likely, that it points to ll
121-
header. PPP makes it, that is wrong, because introduce
122-
assymetry between rx and tx paths.
119+
Incoming, dev->header_ops == NULL
120+
mac_header -> data
121+
However drivers often make it point to the ll header.
122+
This is incorrect because the ll header should be invisible to us.
123123
data -> data
124124
125-
Outgoing, dev->hard_header==NULL
126-
mac_header -> data. ll header is still not built!
125+
Outgoing, dev->header_ops == NULL
126+
mac_header -> data. ll header is invisible to us.
127127
data -> data
128128
129129
Resume
130-
If dev->hard_header==NULL we are unlikely to restore sensible ll header.
130+
If dev->header_ops == NULL we are unable to restore the ll header,
131+
because it is invisible to us.
131132
132133
133134
On transmit:
134135
------------
135136
136-
dev->hard_header != NULL
137+
dev->header_ops != NULL
137138
mac_header -> ll header
138139
data -> ll header
139140
140-
dev->hard_header == NULL (ll header is added by device, we cannot control it)
141+
dev->header_ops == NULL (ll header is invisible to us)
141142
mac_header -> data
142143
data -> data
143144

0 commit comments

Comments
 (0)