Skip to content

Commit c0f25c8

Browse files
lunnsimonwunderlich
authored andcommitted
batman-adv: Include frame priority in fragment header
Unfragmented frames which traverse a node have their skb->priority set by looking at the IP ToS byte, or the 802.1p header. However for fragments this is not possible, only one of the fragments will contain the headers. Instead, place the priority into the fragment header and on receiving a fragment, use this information to set the skb->priority for when the fragment is forwarded. Signed-off-by: Andrew Lunn <[email protected]> Signed-off-by: Marek Lindner <[email protected]> Signed-off-by: Sven Eckelmann <[email protected]> Signed-off-by: Simon Wunderlich <[email protected]>
1 parent 1914848 commit c0f25c8

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

net/batman-adv/fragmentation.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,15 @@ bool batadv_frag_send_packet(struct sk_buff *skb,
472472
frag_header.reserved = 0;
473473
frag_header.no = 0;
474474
frag_header.total_size = htons(skb->len);
475+
476+
/* skb->priority values from 256->263 are magic values to
477+
* directly indicate a specific 802.1d priority. This is used
478+
* to allow 802.1d priority to be passed directly in from VLAN
479+
* tags, etc.
480+
*/
481+
if (skb->priority >= 256 && skb->priority <= 263)
482+
frag_header.priority = skb->priority - 256;
483+
475484
ether_addr_copy(frag_header.orig, primary_if->net_dev->dev_addr);
476485
ether_addr_copy(frag_header.dest, orig_node->orig);
477486

net/batman-adv/packet.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,7 @@ struct batadv_unicast_4addr_packet {
420420
* @dest: final destination used when routing fragments
421421
* @orig: originator of the fragment used when merging the packet
422422
* @no: fragment number within this sequence
423+
* @priority: priority of frame, from ToS IP precedence or 802.1p
423424
* @reserved: reserved byte for alignment
424425
* @seqno: sequence identification
425426
* @total_size: size of the merged packet
@@ -430,9 +431,11 @@ struct batadv_frag_packet {
430431
u8 ttl;
431432
#if defined(__BIG_ENDIAN_BITFIELD)
432433
u8 no:4;
433-
u8 reserved:4;
434+
u8 priority:3;
435+
u8 reserved:1;
434436
#elif defined(__LITTLE_ENDIAN_BITFIELD)
435-
u8 reserved:4;
437+
u8 reserved:1;
438+
u8 priority:3;
436439
u8 no:4;
437440
#else
438441
#error "unknown bitfield endianness"

net/batman-adv/routing.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,6 +1006,8 @@ int batadv_recv_frag_packet(struct sk_buff *skb,
10061006
if (!orig_node_src)
10071007
goto out;
10081008

1009+
skb->priority = frag_packet->priority + 256;
1010+
10091011
/* Route the fragment if it is not for us and too big to be merged. */
10101012
if (!batadv_is_my_mac(bat_priv, frag_packet->dest) &&
10111013
batadv_frag_skb_fwd(skb, recv_if, orig_node_src)) {

0 commit comments

Comments
 (0)