Skip to content

Commit df23e9f

Browse files
Jarno Rajahalmejessegross
authored andcommitted
openvswitch: Widen TCP flags handling.
Widen TCP flags handling from 7 bits (uint8_t) to 12 bits (uint16_t). The kernel interface remains at 8 bits, which makes no functional difference now, as none of the higher bits is currently of interest to the userspace. Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com> Signed-off-by: Jesse Gross <jesse@nicira.com>
1 parent 3cdb35b commit df23e9f

3 files changed

Lines changed: 5 additions & 7 deletions

File tree

‎net/openvswitch/datapath.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -671,7 +671,7 @@ static int ovs_flow_cmd_fill_info(struct sw_flow *flow, struct datapath *dp,
671671
used = flow->used;
672672
stats.n_packets = flow->packet_count;
673673
stats.n_bytes = flow->byte_count;
674-
tcp_flags = flow->tcp_flags;
674+
tcp_flags = (u8)ntohs(flow->tcp_flags);
675675
spin_unlock_bh(&flow->lock);
676676

677677
if (used &&

‎net/openvswitch/flow.c‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,19 +58,17 @@ u64 ovs_flow_used_time(unsigned long flow_jiffies)
5858
return cur_ms - idle_ms;
5959
}
6060

61-
#define TCP_FLAGS_OFFSET 13
62-
#define TCP_FLAG_MASK 0x3f
61+
#define TCP_FLAGS_BE16(tp) (*(__be16 *)&tcp_flag_word(tp) & htons(0x0FFF))
6362

6463
void ovs_flow_used(struct sw_flow *flow, struct sk_buff *skb)
6564
{
66-
u8 tcp_flags = 0;
65+
__be16 tcp_flags = 0;
6766

6867
if ((flow->key.eth.type == htons(ETH_P_IP) ||
6968
flow->key.eth.type == htons(ETH_P_IPV6)) &&
7069
flow->key.ip.proto == IPPROTO_TCP &&
7170
likely(skb->len >= skb_transport_offset(skb) + sizeof(struct tcphdr))) {
72-
u8 *tcp = (u8 *)tcp_hdr(skb);
73-
tcp_flags = *(tcp + TCP_FLAGS_OFFSET) & TCP_FLAG_MASK;
71+
tcp_flags = TCP_FLAGS_BE16(tcp_hdr(skb));
7472
}
7573

7674
spin_lock(&flow->lock);

‎net/openvswitch/flow.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ struct sw_flow {
158158
unsigned long used; /* Last used time (in jiffies). */
159159
u64 packet_count; /* Number of packets matched. */
160160
u64 byte_count; /* Number of bytes matched. */
161-
u8 tcp_flags; /* Union of seen TCP flags. */
161+
__be16 tcp_flags; /* Union of seen TCP flags. */
162162
};
163163

164164
struct arp_eth_header {

0 commit comments

Comments
 (0)