2 * Copyright (c) 2015, 2016 Nicira, Inc.
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:
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 #include "conntrack-private.h"
20 #include "dp-packet.h"
30 enum other_state state
;
33 static 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
,
39 static struct conn_other
*
40 conn_other_cast(const struct conn
*conn
)
42 return CONTAINER_OF(conn
, struct conn_other
, up
);
45 static enum ct_update_res
46 other_conn_update(struct conn
*conn_
, struct conntrack_bucket
*ctb
,
47 struct dp_packet
*pkt OVS_UNUSED
, bool reply
, long long now
)
49 struct conn_other
*conn
= conn_other_cast(conn_
);
51 if (reply
&& conn
->state
!= OTHERS_BIDIR
) {
52 conn
->state
= OTHERS_BIDIR
;
53 } else if (conn
->state
== OTHERS_FIRST
) {
54 conn
->state
= OTHERS_MULTIPLE
;
57 conn_update_expiration(ctb
, &conn
->up
, other_timeouts
[conn
->state
], now
);
59 return CT_UPDATE_VALID
;
63 other_valid_new(struct dp_packet
*pkt OVS_UNUSED
)
69 other_new_conn(struct conntrack_bucket
*ctb
, struct dp_packet
*pkt OVS_UNUSED
,
72 struct conn_other
*conn
;
74 conn
= xzalloc(sizeof *conn
);
75 conn
->state
= OTHERS_FIRST
;
77 conn_init_expiration(ctb
, &conn
->up
, other_timeouts
[conn
->state
], now
);
82 struct ct_l4_proto ct_proto_other
= {
83 .new_conn
= other_new_conn
,
84 .valid_new
= other_valid_new
,
85 .conn_update
= other_conn_update
,