forked from openvswitch/ovs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ofproto: Add a fixed bundle idle timeout of 10 seconds.
Timing out idle bundles frees memory that would effectively be leaked if a long standing OpenFlow connection would fail to commit or discard a bundle. OpenFlow specification mandates the timeout to be at least one second, if the switch implements such a timeout. This patch makes the bundle idle timeout to be 10 seconds. We do not limit the number of messages in a bundle, so it does not make sense to limit the number of bundles either, especially now that idle bundles are timed out. Signed-off-by: Jarno Rajahalme <[email protected]> Acked-by: Ben Pfaff <[email protected]>
- Loading branch information
Jarno Rajahalme
committed
Sep 13, 2016
1 parent
68030e1
commit 51bb26f
Showing
7 changed files
with
150 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
/* | ||
* Copyright (c) 2013, 2014 Alexandru Copot <[email protected]>, with support from IXIA. | ||
* Copyright (c) 2013, 2014 Daniel Baluta <[email protected]> | ||
* Copyright (c) 2014, 2015 Nicira, Inc. | ||
* Copyright (c) 2014, 2015, 2016 Nicira, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
|
@@ -41,18 +41,23 @@ | |
VLOG_DEFINE_THIS_MODULE(bundles); | ||
|
||
static struct ofp_bundle * | ||
ofp_bundle_create(uint32_t id, uint16_t flags) | ||
ofp_bundle_create(uint32_t id, uint16_t flags, const struct ofp_header *oh) | ||
{ | ||
struct ofp_bundle *bundle; | ||
|
||
bundle = xmalloc(sizeof(*bundle)); | ||
|
||
bundle->used = time_msec(); | ||
bundle->id = id; | ||
bundle->flags = flags; | ||
bundle->state = BS_OPEN; | ||
|
||
ovs_list_init(&bundle->msg_list); | ||
|
||
/* Max 64 bytes for error reporting. */ | ||
memcpy(bundle->ofp_msg_data, oh, | ||
MIN(ntohs(oh->length), sizeof bundle->ofp_msg_data)); | ||
|
||
return bundle; | ||
} | ||
|
||
|
@@ -75,7 +80,8 @@ ofp_bundle_remove__(struct ofconn *ofconn, struct ofp_bundle *bundle, | |
} | ||
|
||
enum ofperr | ||
ofp_bundle_open(struct ofconn *ofconn, uint32_t id, uint16_t flags) | ||
ofp_bundle_open(struct ofconn *ofconn, uint32_t id, uint16_t flags, | ||
const struct ofp_header *oh) | ||
{ | ||
struct ofp_bundle *bundle; | ||
enum ofperr error; | ||
|
@@ -89,7 +95,7 @@ ofp_bundle_open(struct ofconn *ofconn, uint32_t id, uint16_t flags) | |
return OFPERR_OFPBFC_BAD_ID; | ||
} | ||
|
||
bundle = ofp_bundle_create(id, flags); | ||
bundle = ofp_bundle_create(id, flags, oh); | ||
error = ofconn_insert_bundle(ofconn, bundle); | ||
if (error) { | ||
free(bundle); | ||
|
@@ -119,6 +125,7 @@ ofp_bundle_close(struct ofconn *ofconn, uint32_t id, uint16_t flags) | |
return OFPERR_OFPBFC_BAD_FLAGS; | ||
} | ||
|
||
bundle->used = time_msec(); | ||
bundle->state = BS_CLOSED; | ||
return 0; | ||
} | ||
|
@@ -141,7 +148,8 @@ ofp_bundle_discard(struct ofconn *ofconn, uint32_t id) | |
|
||
enum ofperr | ||
ofp_bundle_add_message(struct ofconn *ofconn, uint32_t id, uint16_t flags, | ||
struct ofp_bundle_entry *bmsg) | ||
struct ofp_bundle_entry *bmsg, | ||
const struct ofp_header *oh) | ||
{ | ||
struct ofp_bundle *bundle; | ||
|
||
|
@@ -150,7 +158,7 @@ ofp_bundle_add_message(struct ofconn *ofconn, uint32_t id, uint16_t flags, | |
if (!bundle) { | ||
enum ofperr error; | ||
|
||
bundle = ofp_bundle_create(id, flags); | ||
bundle = ofp_bundle_create(id, flags, oh); | ||
error = ofconn_insert_bundle(ofconn, bundle); | ||
if (error) { | ||
free(bundle); | ||
|
@@ -164,6 +172,7 @@ ofp_bundle_add_message(struct ofconn *ofconn, uint32_t id, uint16_t flags, | |
return OFPERR_OFPBFC_BAD_FLAGS; | ||
} | ||
|
||
bundle->used = time_msec(); | ||
ovs_list_push_back(&bundle->msg_list, &bmsg->node); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters