]> git.proxmox.com Git - mirror_ovs.git/blame - lib/conntrack-private.h
dpdk: Remove batch sorting in userspace conntrack.
[mirror_ovs.git] / lib / conntrack-private.h
CommitLineData
a489b168
DDP
1/*
2 * Copyright (c) 2015, 2016 Nicira, Inc.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at:
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef CONNTRACK_PRIVATE_H
18#define CONNTRACK_PRIVATE_H 1
19
20#include <sys/types.h>
21#include <netinet/in.h>
22#include <netinet/ip6.h>
23
24#include "conntrack.h"
4d4e68ed 25#include "ct-dpif.h"
a489b168
DDP
26#include "openvswitch/hmap.h"
27#include "openvswitch/list.h"
28#include "openvswitch/types.h"
29#include "packets.h"
30#include "unaligned.h"
31
a489b168
DDP
32struct ct_endpoint {
33 struct ct_addr addr;
b269a122
DDP
34 union {
35 ovs_be16 port;
36 struct {
37 ovs_be16 icmp_id;
38 uint8_t icmp_type;
39 uint8_t icmp_code;
40 };
41 };
a489b168
DDP
42};
43
44/* Changes to this structure need to be reflected in conn_key_hash() */
45struct conn_key {
46 struct ct_endpoint src;
47 struct ct_endpoint dst;
48
49 ovs_be16 dl_type;
50 uint8_t nw_proto;
51 uint16_t zone;
52};
53
54struct conn {
55 struct conn_key key;
56 struct conn_key rev_key;
57 long long expiration;
58 struct ovs_list exp_node;
59 struct hmap_node node;
60 uint32_t mark;
61 ovs_u128 label;
62};
63
64enum ct_update_res {
65 CT_UPDATE_INVALID,
66 CT_UPDATE_VALID,
67 CT_UPDATE_NEW,
68};
69
70struct ct_l4_proto {
e6ef6cc6
DDP
71 struct conn *(*new_conn)(struct conntrack_bucket *, struct dp_packet *pkt,
72 long long now);
a489b168 73 bool (*valid_new)(struct dp_packet *pkt);
e6ef6cc6
DDP
74 enum ct_update_res (*conn_update)(struct conn *conn,
75 struct conntrack_bucket *,
76 struct dp_packet *pkt, bool reply,
77 long long now);
4d4e68ed
DDP
78 void (*conn_get_protoinfo)(const struct conn *,
79 struct ct_dpif_protoinfo *);
a489b168
DDP
80};
81
82extern struct ct_l4_proto ct_proto_tcp;
83extern struct ct_l4_proto ct_proto_other;
b269a122
DDP
84extern struct ct_l4_proto ct_proto_icmp4;
85extern struct ct_l4_proto ct_proto_icmp6;
a489b168
DDP
86
87extern long long ct_timeout_val[];
88
89static inline void
e6ef6cc6
DDP
90conn_init_expiration(struct conntrack_bucket *ctb, struct conn *conn,
91 enum ct_timeout tm, long long now)
a489b168
DDP
92{
93 conn->expiration = now + ct_timeout_val[tm];
e6ef6cc6
DDP
94 ovs_list_push_back(&ctb->exp_lists[tm], &conn->exp_node);
95}
96
97static inline void
98conn_update_expiration(struct conntrack_bucket *ctb, struct conn *conn,
99 enum ct_timeout tm, long long now)
100{
101 ovs_list_remove(&conn->exp_node);
102 conn_init_expiration(ctb, conn, tm, now);
a489b168
DDP
103}
104
105#endif /* conntrack-private.h */