]> git.proxmox.com Git - mirror_ovs.git/blame - lib/conntrack-other.c
odp-execute: Rename 'may_steal' to 'should_steal'.
[mirror_ovs.git] / lib / conntrack-other.c
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#include <config.h>
18
19#include "conntrack-private.h"
20#include "dp-packet.h"
21
22enum other_state {
23 OTHERS_FIRST,
24 OTHERS_MULTIPLE,
25 OTHERS_BIDIR,
26};
27
28struct conn_other {
29 struct conn up;
30 enum other_state state;
31};
32
33static const enum ct_timeout other_timeouts[] = {
34 [OTHERS_FIRST] = CT_TM_OTHER_FIRST,
35 [OTHERS_MULTIPLE] = CT_TM_OTHER_MULTIPLE,
36 [OTHERS_BIDIR] = CT_TM_OTHER_BIDIR,
37};
38
39static struct conn_other *
40conn_other_cast(const struct conn *conn)
41{
42 return CONTAINER_OF(conn, struct conn_other, up);
43}
44
45static enum ct_update_res
e6ef6cc6
DDP
46other_conn_update(struct conn *conn_, struct conntrack_bucket *ctb,
47 struct dp_packet *pkt OVS_UNUSED, bool reply, long long now)
a489b168
DDP
48{
49 struct conn_other *conn = conn_other_cast(conn_);
50
51 if (reply && conn->state != OTHERS_BIDIR) {
52 conn->state = OTHERS_BIDIR;
53 } else if (conn->state == OTHERS_FIRST) {
54 conn->state = OTHERS_MULTIPLE;
55 }
56
e6ef6cc6 57 conn_update_expiration(ctb, &conn->up, other_timeouts[conn->state], now);
a489b168
DDP
58
59 return CT_UPDATE_VALID;
60}
61
62static bool
63other_valid_new(struct dp_packet *pkt OVS_UNUSED)
64{
65 return true;
66}
67
68static struct conn *
e6ef6cc6
DDP
69other_new_conn(struct conntrack_bucket *ctb, struct dp_packet *pkt OVS_UNUSED,
70 long long now)
a489b168
DDP
71{
72 struct conn_other *conn;
73
74 conn = xzalloc(sizeof *conn);
75 conn->state = OTHERS_FIRST;
76
e6ef6cc6 77 conn_init_expiration(ctb, &conn->up, other_timeouts[conn->state], now);
a489b168
DDP
78
79 return &conn->up;
80}
81
82struct ct_l4_proto ct_proto_other = {
83 .new_conn = other_new_conn,
84 .valid_new = other_valid_new,
85 .conn_update = other_conn_update,
86};