2
0
mirror of https://github.com/openvswitch/ovs synced 2025-10-17 14:28:02 +00:00

BFD: Add check_tnl_key feature to BFD code.

This change adds the check_tnl_key functionality for BFD.
When the feature is enabled, BFD will only accept control
packets with a tunnel key of 0.

Signed-off-by: Pavithra Ramesh <paramesh@vmware.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
This commit is contained in:
Pavithra Ramesh
2013-07-16 09:58:42 +00:00
committed by Ethan Jackson
parent aad84c8ef1
commit fab52e16f7
4 changed files with 18 additions and 8 deletions

View File

@@ -58,10 +58,6 @@ VLOG_DEFINE_THIS_MODULE(bfd);
*
* - Set TOS/PCP on inner BFD frame, and outer tunnel header when encapped.
*
* - CFM "check_tnl_key" option equivalent.
*
* - CFM "fault override" equivalent.
*
* - Sending BFD messages should be in its own thread/process.
*
* - Scale testing. How does it operate when there are large number of bfd
@@ -182,6 +178,7 @@ struct bfd {
int ref_cnt;
int forwarding_override; /* Manual override of 'forwarding' status. */
bool check_tnl_key; /* Verify tunnel key of inbound packets? */
};
static bool bfd_in_poll(const struct bfd *);
@@ -287,6 +284,7 @@ bfd_configure(struct bfd *bfd, const char *name,
bfd_set_state(bfd, STATE_DOWN, DIAG_NONE);
}
bfd->check_tnl_key = smap_get_bool(cfg, "check_tnl_key", false);
min_tx = smap_get_int(cfg, "min_tx", 100);
min_tx = MAX(min_tx, 100);
if (bfd->cfg_min_tx != min_tx) {
@@ -449,13 +447,18 @@ bfd_put_packet(struct bfd *bfd, struct ofpbuf *p,
}
bool
bfd_should_process_flow(const struct flow *flow, struct flow_wildcards *wc)
bfd_should_process_flow(const struct bfd *bfd, const struct flow *flow,
struct flow_wildcards *wc)
{
memset(&wc->masks.nw_proto, 0xff, sizeof wc->masks.nw_proto);
memset(&wc->masks.tp_dst, 0xff, sizeof wc->masks.tp_dst);
if (bfd->check_tnl_key) {
memset(&wc->masks.tunnel.tun_id, 0xff, sizeof wc->masks.tunnel.tun_id);
}
return (flow->dl_type == htons(ETH_TYPE_IP)
&& flow->nw_proto == IPPROTO_UDP
&& flow->tp_dst == htons(3784));
&& flow->tp_dst == htons(3784)
&& (!bfd->check_tnl_key || flow->tunnel.tun_id == htonl(0)));
}
void

View File

@@ -34,7 +34,8 @@ bool bfd_should_send_packet(const struct bfd *);
void bfd_put_packet(struct bfd *bfd, struct ofpbuf *packet,
uint8_t eth_src[6]);
bool bfd_should_process_flow(const struct flow *, struct flow_wildcards *);
bool bfd_should_process_flow(const struct bfd *, const struct flow *,
struct flow_wildcards *);
void bfd_process_packet(struct bfd *, const struct flow *,
const struct ofpbuf *);

View File

@@ -1193,7 +1193,7 @@ process_special(struct xlate_ctx *ctx, const struct flow *flow,
cfm_process_heartbeat(xport->cfm, packet);
}
return SLOW_CFM;
} else if (xport->bfd && bfd_should_process_flow(flow, wc)) {
} else if (xport->bfd && bfd_should_process_flow(xport->bfd, flow, wc)) {
if (packet) {
bfd_process_packet(xport->bfd, flow, packet);
}

View File

@@ -1890,6 +1890,12 @@
<code>false</code>.
</column>
<column name="bfd" key="check_tnl_key" type='{"type": "boolean"}'>
When set to true, Check Tunnel Key will make BFD only accept control
messages with an <code>in_key</code> of zero. Defaults to
<code>false</code>.
</column>
<column name="bfd_status" key="state"
type='{"type": "string",
"enum": ["set", ["admin_down", "down", "init", "up"]]}'>