mirror of
https://github.com/openvswitch/ovs
synced 2025-08-31 14:25:26 +00:00
Implement new fragment handling policy.
Until now, OVS has handled IP fragments more awkwardly than necessary. It has not been possible to match on L4 headers, even in fragments with offset 0 where they are actually present. This means that there was no way to implement ACLs that treat, say, different TCP ports differently, on fragmented traffic; instead, all decisions for fragment forwarding had to be made on the basis of L2 and L3 headers alone. This commit improves the situation significantly. It is still not possible to match on L4 headers in fragments with nonzero offset, because that information is simply not present in such fragments, but this commit adds the ability to match on L4 headers for fragments with zero offset. This means that it becomes possible to implement ACLs that drop such "first fragments" on the basis of L4 headers. In practice, that effectively blocks even fragmented traffic on an L4 basis, because the receiving IP stack cannot reassemble a full packet when the first fragment is missing. This commit works by adding a new "fragment type" to the kernel flow match and making it available through OpenFlow as a new NXM field named NXM_NX_IP_FRAG. Because OpenFlow 1.0 explicitly says that the L4 fields are always 0 for IP fragments, it adds a new OpenFlow fragment handling mode that fills in the L4 fields for "first fragments". It also enhances ovs-ofctl to allow users to configure this new fragment handling mode and to parse the new field. Signed-off-by: Ben Pfaff <blp@nicira.com> Bug #7557.
This commit is contained in:
@@ -81,12 +81,10 @@ struct dp_netdev {
|
||||
int open_cnt;
|
||||
bool destroyed;
|
||||
|
||||
bool drop_frags; /* Drop all IP fragments, if true. */
|
||||
struct dp_netdev_queue queues[N_QUEUES];
|
||||
struct hmap flow_table; /* Flow table. */
|
||||
|
||||
/* Statistics. */
|
||||
long long int n_frags; /* Number of dropped IP fragments. */
|
||||
long long int n_hit; /* Number of flow table matches. */
|
||||
long long int n_missed; /* Number of flow table misses. */
|
||||
long long int n_lost; /* Number of misses not passed to client. */
|
||||
@@ -198,7 +196,6 @@ create_dp_netdev(const char *name, const struct dpif_class *class,
|
||||
dp->class = class;
|
||||
dp->name = xstrdup(name);
|
||||
dp->open_cnt = 0;
|
||||
dp->drop_frags = false;
|
||||
for (i = 0; i < N_QUEUES; i++) {
|
||||
dp->queues[i].head = dp->queues[i].tail = 0;
|
||||
}
|
||||
@@ -302,29 +299,12 @@ dpif_netdev_get_stats(const struct dpif *dpif, struct dpif_dp_stats *stats)
|
||||
{
|
||||
struct dp_netdev *dp = get_dp_netdev(dpif);
|
||||
stats->n_flows = hmap_count(&dp->flow_table);
|
||||
stats->n_frags = dp->n_frags;
|
||||
stats->n_hit = dp->n_hit;
|
||||
stats->n_missed = dp->n_missed;
|
||||
stats->n_lost = dp->n_lost;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
dpif_netdev_get_drop_frags(const struct dpif *dpif, bool *drop_fragsp)
|
||||
{
|
||||
struct dp_netdev *dp = get_dp_netdev(dpif);
|
||||
*drop_fragsp = dp->drop_frags;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
dpif_netdev_set_drop_frags(struct dpif *dpif, bool drop_frags)
|
||||
{
|
||||
struct dp_netdev *dp = get_dp_netdev(dpif);
|
||||
dp->drop_frags = drop_frags;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
do_add_port(struct dp_netdev *dp, const char *devname, const char *type,
|
||||
uint16_t port_no)
|
||||
@@ -1001,11 +981,7 @@ dp_netdev_port_input(struct dp_netdev *dp, struct dp_netdev_port *port,
|
||||
if (packet->size < ETH_HEADER_LEN) {
|
||||
return;
|
||||
}
|
||||
if (flow_extract(packet, 0, port->port_no, &key) && dp->drop_frags) {
|
||||
dp->n_frags++;
|
||||
return;
|
||||
}
|
||||
|
||||
flow_extract(packet, 0, port->port_no, &key);
|
||||
flow = dp_netdev_lookup_flow(dp, &key);
|
||||
if (flow) {
|
||||
dp_netdev_flow_used(flow, &key, packet);
|
||||
@@ -1364,8 +1340,6 @@ const struct dpif_class dpif_netdev_class = {
|
||||
dpif_netdev_run,
|
||||
dpif_netdev_wait,
|
||||
dpif_netdev_get_stats,
|
||||
dpif_netdev_get_drop_frags,
|
||||
dpif_netdev_set_drop_frags,
|
||||
dpif_netdev_port_add,
|
||||
dpif_netdev_port_del,
|
||||
dpif_netdev_port_query_by_number,
|
||||
|
Reference in New Issue
Block a user