Eli Britstein via dev <[email protected]> writes:
> IP reassembly must not accept data past an MF=0 fragment. Track
> last fragments, reject ranges beyond them on insert, and require the
> sorted rightmost fragment to be MF=0 before completing a list.
>
> If an MF=0 fragment arrives as an exact duplicate and no data is queued
> beyond it, keep that copy so the forwarded fragments end with MF=0 and the
> datagram can still complete. If data is queued
> beyond it, the duplicate is dropped on its own.
>
> The accompanying tests are added to tests/ofproto-dpif.at (using
> netdev-dummy/receive with variable-built packets and precomputed IPv4
> header checksums) rather than the system-traffic suite.
This paragraph reads more like some kind of internal note. Is there
something about the rationale that you were intending to convey (maybe
*why* it lives in the ofproto-dpif suite rather than the system-traffic
suite)? Otherwise, it can just be dropped.
> Assisted-by: composer-2.5-fast, Cursor
> Fixes: 4ea96698f667 ("Userspace datapath: Add fragmentation handling.")
> Signed-off-by: Eli Britstein <[email protected]>
> ---
> lib/dpctl.c | 4 +
> lib/dpif-provider.h | 1 +
> lib/ipf.c | 77 ++++++-
> lib/ipf.h | 1 +
> tests/ofproto-dpif.at | 340 +++++++++++++++++++++++++++++++
> tests/system-userspace-macros.at | 8 +
> 6 files changed, 426 insertions(+), 5 deletions(-)
>
> diff --git a/lib/dpctl.c b/lib/dpctl.c
> index dc3b68c01..d117e3d56 100644
> --- a/lib/dpctl.c
> +++ b/lib/dpctl.c
> @@ -2633,6 +2633,8 @@ dpctl_ct_ipf_get_status(int argc, const char *argv[],
> dpif_ipf_status.v4.nfrag_duplicate);
> dpctl_print(dpctl_p, " v4 frags discarded: %"PRIu64"\n",
> dpif_ipf_status.v4.nfrag_discarded);
> + dpctl_print(dpctl_p, " v4 frags beyond last: %"PRIu64"\n",
> + dpif_ipf_status.v4.nfrag_beyond_last);
> dpctl_print(dpctl_p, " v4 frags purged: %"PRIu64"\n",
> dpif_ipf_status.v4.nfrag_purged);
>
> @@ -2654,6 +2656,8 @@ dpctl_ct_ipf_get_status(int argc, const char *argv[],
> dpif_ipf_status.v6.nfrag_duplicate);
> dpctl_print(dpctl_p, " v6 frags discarded: %"PRIu64"\n",
> dpif_ipf_status.v6.nfrag_discarded);
> + dpctl_print(dpctl_p, " v6 frags beyond last: %"PRIu64"\n",
> + dpif_ipf_status.v6.nfrag_beyond_last);
> dpctl_print(dpctl_p, " v6 frags purged: %"PRIu64"\n",
> dpif_ipf_status.v6.nfrag_purged);
> } else {
> diff --git a/lib/dpif-provider.h b/lib/dpif-provider.h
> index f418327df..e1998151c 100644
> --- a/lib/dpif-provider.h
> +++ b/lib/dpif-provider.h
> @@ -133,6 +133,7 @@ struct dpif_ipf_proto_status {
> uint64_t nfrag_overlap;
> uint64_t nfrag_duplicate;
> uint64_t nfrag_discarded;
> + uint64_t nfrag_beyond_last;
> uint64_t nfrag_purged;
> unsigned int min_frag_size;
> bool enabled;
> diff --git a/lib/ipf.c b/lib/ipf.c
> index 87ff5b4b9..2748fb123 100644
> --- a/lib/ipf.c
> +++ b/lib/ipf.c
> @@ -86,6 +86,7 @@ enum ipf_counter_type {
> IPF_NFRAGS_OVERLAP,
> IPF_NFRAGS_DUPLICATE,
> IPF_NFRAGS_DISCARDED,
> + IPF_NFRAGS_BEYOND_LAST,
> IPF_NFRAGS_PURGED,
> IPF_NFRAGS_NUM_CNTS,
> };
> @@ -100,6 +101,7 @@ struct ipf_frag {
> struct dp_packet *pkt;
> uint16_t start_data_byte;
> uint16_t end_data_byte;
> + bool last_frag; /* True if this was the MF=0 fragment. */
> };
>
> /* The key for a collection of fragments potentially making up an
> unfragmented
> @@ -399,8 +401,14 @@ ipf_list_complete(const struct ipf_list *ipf_list)
> != ipf_list->frag_list[i].start_data_byte) {
> return false;
> }
> +
> + /* Only the final fragment may have MF=0, data past it is invalid. */
> + if (ipf_list->frag_list[i - 1].last_frag) {
> + return false;
> + }
> }
> - return true;
> +
> + return ipf_list->frag_list[ipf_list->last_inuse_idx].last_frag;
> }
>
> /* Runs O(n) for a sorted or almost sorted list. */
> @@ -896,6 +904,32 @@ ipf_is_frag_overlap(const struct ipf_frag *frag_list,
> int last_inuse_idx,
> return false;
> }
>
> +/* Returns true if accepting this fragment would be inconsistent with an
> + * MF=0 (last) fragment. The last fragment fixes the datagram's total
> length,
> + * so any octet at a higher offset is invalid per the IPv4 (RFC 791) and IPv6
> + * (RFC 8200, Section 4.5) reassembly procedures. This covers two cases, a
> + * fragment starting past an already seen last fragment, and an incoming last
> + * fragment that ends before data already queued beyond it. */
> +static bool
> +ipf_is_beyond_last_frag(const struct ipf_frag *frag_list, int last_inuse_idx,
> + uint16_t start_data_byte, uint16_t end_data_byte,
> + bool lf)
> + /* OVS_REQUIRES(ipf_lock) */
> +{
> + for (int i = 0; i <= last_inuse_idx; i++) {
> + if (frag_list[i].last_frag
> + && start_data_byte > frag_list[i].end_data_byte) {
> + return true;
> + }
> +
> + if (lf && frag_list[i].end_data_byte > end_data_byte) {
> + return true;
> + }
> + }
> +
> + return false;
> +}
> +
> /* Drops the entire fragment list: deletes every fragment packet held by the
> * list and removes the list from the tracking datastructures. Per RFC 5722
> * and RFC 8200, when an overlapping fragment is detected the whole datagram
> @@ -916,7 +950,9 @@ ipf_drop_frag_chain(struct ipf *ipf, struct ipf_list
> *ipf_list, bool v6)
> /* Adds a fragment to a list of fragments. An exact duplicate fragment is
> * dropped on its own, keeping the rest of the list (RFC 8200). An
> * overlapping (but not duplicate) fragment causes the whole fragment list to
> - * be dropped (see ipf_drop_frag_chain(), RFC 5722 / RFC 8200). */
> + * be dropped (see ipf_drop_frag_chain(), RFC 5722 / RFC 8200). A fragment
> + * with data beyond an already seen last (MF=0) fragment is dropped on its
> own
> + * (RFC 791 / RFC 8200). */
> static bool
> ipf_process_frag(struct ipf *ipf, struct ipf_list *ipf_list,
> struct dp_packet *pkt, uint16_t start_data_byte,
> @@ -928,14 +964,17 @@ ipf_process_frag(struct ipf *ipf, struct ipf_list
> *ipf_list,
> ipf_list->last_inuse_idx, start_data_byte, end_data_byte);
> bool overlap_frag = ipf_is_frag_overlap(ipf_list->frag_list,
> ipf_list->last_inuse_idx, start_data_byte, end_data_byte);
> + bool beyond_last = ipf_is_beyond_last_frag(ipf_list->frag_list,
> + ipf_list->last_inuse_idx, start_data_byte, end_data_byte, lf);
> int last_inuse_idx = ipf_list->last_inuse_idx;
>
> - if (!duped_frag && !overlap_frag) {
> + if (!duped_frag && !overlap_frag && !beyond_last) {
> if (last_inuse_idx < ipf_list->size - 1) {
> struct ipf_frag *frag = &ipf_list->frag_list[last_inuse_idx + 1];
> frag->pkt = pkt;
> frag->start_data_byte = start_data_byte;
> frag->end_data_byte = end_data_byte;
> + frag->last_frag = lf;
> ipf_list->last_inuse_idx++;
> atomic_count_inc(&ipf->nfrag);
> ipf_count(ipf, v6, IPF_NFRAGS_ACCEPTED);
> @@ -945,14 +984,38 @@ ipf_process_frag(struct ipf *ipf, struct ipf_list
> *ipf_list,
> }
> } else if (duped_frag) {
> /* RFC 8200: an exact duplicate may be dropped while keeping the rest
> - * of the fragment list for later reassembly. */
> + * of the fragment list for later reassembly. If it is a consistent
> + * last fragment and the stored copy was not marked last, keep the
> + * MF=0 copy so the forwarded fragments end with MF=0. */
> ipf_count(ipf, v6, IPF_NFRAGS_DUPLICATE);
I guess there's a missing count case here - if a frag is dup &&
beyond_last - but I'm not sure how likely that is to happen. Just
noting it because you explicitly compare against !beyond_last below. If
such a case could happen, I guess we want at least a coverage for it,
otherwise we silently drop it.
> + if (lf && !beyond_last) {
> + struct ipf_frag *frag_list = ipf_list->frag_list;
> +
> + for (int i = 0; i <= ipf_list->last_inuse_idx; i++) {
> + if (start_data_byte == frag_list[i].start_data_byte &&
> + end_data_byte == frag_list[i].end_data_byte &&
> + !frag_list[i].last_frag) {
Am I understanding correctly that we are overwriting the fragment here
because the 5-tuple, id, and byte ranges match? Seems weird to me, and
I looked a bit at other implementations and most follow an errata'd RFC
5722:
Duplicates, however, should be ignored...
So I guess we should just be keeping the contents of the previously seen
packet rather than replacing the old one. If we go with discarding the
new packet, the "last fragment arrives as a duplicate" test below needs
to be reworked a bit - it asserts the swap behavior. It is better to
make sure the test asserts *which* fragment will be forwarded so it
doesn't regress.
> + struct dp_packet *stored = frag_list[i].pkt;
> +
> + frag_list[i].pkt = pkt;
> + frag_list[i].last_frag = true;
> + pkt = stored;
> + *rp = ipf_list_state_transition(ipf, ipf_list, ff, lf,
> v6);
> + break;
> + }
> + }
> + }
> +
> dp_packet_delete(pkt);
> - } else {
> + } else if (overlap_frag) {
> ipf_count(ipf, v6, IPF_NFRAGS_OVERLAP);
> dp_packet_delete(pkt);
> ipf_drop_frag_chain(ipf, ipf_list, v6);
> + } else {
> + ipf_count(ipf, v6, IPF_NFRAGS_BEYOND_LAST);
> + dp_packet_delete(pkt);
> }
> +
> return true;
> }
>
> @@ -1551,6 +1614,8 @@ ipf_get_status(struct ipf *ipf, struct ipf_status
> *ipf_status)
> &ipf_status->v4.nfrag_duplicate);
> atomic_read_relaxed(&ipf->n4frag_cnt[IPF_NFRAGS_DISCARDED],
> &ipf_status->v4.nfrag_discarded);
> + atomic_read_relaxed(&ipf->n4frag_cnt[IPF_NFRAGS_BEYOND_LAST],
> + &ipf_status->v4.nfrag_beyond_last);
> atomic_read_relaxed(&ipf->n4frag_cnt[IPF_NFRAGS_PURGED],
> &ipf_status->v4.nfrag_purged);
>
> @@ -1573,6 +1638,8 @@ ipf_get_status(struct ipf *ipf, struct ipf_status
> *ipf_status)
> &ipf_status->v6.nfrag_duplicate);
> atomic_read_relaxed(&ipf->n6frag_cnt[IPF_NFRAGS_DISCARDED],
> &ipf_status->v6.nfrag_discarded);
> + atomic_read_relaxed(&ipf->n6frag_cnt[IPF_NFRAGS_BEYOND_LAST],
> + &ipf_status->v6.nfrag_beyond_last);
> atomic_read_relaxed(&ipf->n6frag_cnt[IPF_NFRAGS_PURGED],
> &ipf_status->v6.nfrag_purged);
> return 0;
> diff --git a/lib/ipf.h b/lib/ipf.h
> index c8aec5a5a..0093372de 100644
> --- a/lib/ipf.h
> +++ b/lib/ipf.h
> @@ -31,6 +31,7 @@ struct ipf_proto_status {
> uint64_t nfrag_overlap;
> uint64_t nfrag_duplicate;
> uint64_t nfrag_discarded;
> + uint64_t nfrag_beyond_last;
> uint64_t nfrag_purged;
> unsigned int min_frag_size;
> bool enabled;
> diff --git a/tests/ofproto-dpif.at b/tests/ofproto-dpif.at
> index 6fa944375..813562ac0 100644
> --- a/tests/ofproto-dpif.at
> +++ b/tests/ofproto-dpif.at
> @@ -5850,6 +5850,346 @@ AT_CHECK([ovs-appctl dpctl/ipf-get-status -m \
> OVS_VSWITCHD_STOP
> AT_CLEANUP
>
> +AT_SETUP([ofproto-dpif - fragment handling - reject fragment beyond last])
> +OVS_VSWITCHD_START
> +add_of_ports br0 1 90
> +
> +AT_DATA([flows.txt], [dnl
> +table=0 in_port=90,ip actions=ct(commit),output:1
> +])
> +AT_CHECK([ovs-ofctl -O OpenFlow11 replace-flows br0 flows.txt])
> +
> +dnl The minimum fragment size is clamped to 400 bytes, so a non-last fragment
> +dnl must be at least that large to be admitted for reassembly.
> +AT_CHECK([ovs-appctl dpctl/ipf-set-min-frag v4 400], [], [dnl
> +setting minimum fragment size successful
> +])
> +
> +dnl First admit a last (MF=0) fragment carrying bytes 400..799, then reject a
> +dnl new fragment carrying bytes 800..1199, whose data lies entirely beyond
> the
> +dnl end of the last fragment and so must not be reassembled.
> +dnl
> +dnl Packet 1 (admitted). Last fragment carrying bytes 400..799 (MF clear).
> +dnl Ethernet II, Src: 50:54:00:00:00:09, Dst: 50:54:00:00:00:0a
> +dnl Type: IPv4 (0x0800)
> +dnl Internet Protocol Version 4, Src: 10.1.1.1, Dst: 10.1.1.2
> +dnl 0100 .... = Version: 4
> +dnl .... 0101 = Header Length: 20 bytes (5)
> +dnl Differentiated Services Field: 0x00 (DSCP: CS0, ECN: Not-ECT)
> +dnl Total Length: 420
> +dnl Identification: 0x0020 (32)
> +dnl 000. .... = Flags: 0x0 (Last fragment)
> +dnl ...0 0000 0011 0010 = Fragment Offset: 400
> +dnl Time to Live: 64
> +dnl Protocol: UDP (17)
> +dnl Header Checksum: 0x62f3
> +dnl Data (400 bytes)
> +eth="50 54 00 00 00 0a 50 54 00 00 00 09 08 00"
> +ip1="45 00 01 a4 00 20 00 32 40 11 62 f3"
> +addrs="0a 01 01 01 0a 01 01 02"
> +data1=$(printf '%0*d' 800 0)
> +packet1="${eth}${ip1}${addrs}${data1}"
> +
> +dnl Packet 2 (rejected as beyond last). Fragment carrying bytes 800..1199
> +dnl (MF set), starting past packet 1's last-fragment end.
> +dnl Ethernet II, Src: 50:54:00:00:00:09, Dst: 50:54:00:00:00:0a
> +dnl Type: IPv4 (0x0800)
> +dnl Internet Protocol Version 4, Src: 10.1.1.1, Dst: 10.1.1.2
> +dnl 0100 .... = Version: 4
> +dnl .... 0101 = Header Length: 20 bytes (5)
> +dnl Differentiated Services Field: 0x00 (DSCP: CS0, ECN: Not-ECT)
> +dnl Total Length: 420
> +dnl Identification: 0x0020 (32)
> +dnl 001. .... = Flags: 0x1 (More fragments)
> +dnl ...0 0000 0110 0100 = Fragment Offset: 800
> +dnl Time to Live: 64
> +dnl Protocol: UDP (17)
> +dnl Header Checksum: 0x42c1
> +dnl Data (400 bytes)
> +ip2="45 00 01 a4 00 20 20 64 40 11 42 c1"
> +data2=$(printf '%0*d' 800 0)
> +packet2="${eth}${ip2}${addrs}${data2}"
> +
> +AT_CHECK([ovs-appctl netdev-dummy/receive p90 "$packet1"])
> +AT_CHECK([ovs-appctl netdev-dummy/receive p90 "$packet2"])
> +
> +AT_CHECK([ovs-appctl dpctl/ipf-get-status -m \
> +| grep -E 'num frag:|v4 frags accepted:|v4 frags completed:|v4 frags beyond
> last:'], [], [dnl
> + num frag: 1
> + v4 frags accepted: 1
> + v4 frags completed: 0
> + v4 frags beyond last: 1
> +])
> +
> +dnl The rejected fragment left the last (MF=0) fragment queued. Send the
> +dnl missing first fragment, bytes 0..399 (MF set), and confirm the retained
> +dnl list reassembles.
> +dnl
> +dnl Packet 3 (admitted). First fragment carrying bytes 0..399 (MF set).
> +dnl Ethernet II, Src: 50:54:00:00:00:09, Dst: 50:54:00:00:00:0a
> +dnl Type: IPv4 (0x0800)
> +dnl Internet Protocol Version 4, Src: 10.1.1.1, Dst: 10.1.1.2
> +dnl 0100 .... = Version: 4
> +dnl .... 0101 = Header Length: 20 bytes (5)
> +dnl Differentiated Services Field: 0x00 (DSCP: CS0, ECN: Not-ECT)
> +dnl Total Length: 420
> +dnl Identification: 0x0020 (32)
> +dnl 001. .... = Flags: 0x1 (More fragments)
> +dnl ...0 0000 0000 0000 = Fragment Offset: 0
> +dnl Time to Live: 64
> +dnl Protocol: UDP (17)
> +dnl Header Checksum: 0x4325
> +dnl Data (400 bytes)
> +ip3="45 00 01 a4 00 20 20 00 40 11 43 25"
> +data3=$(printf '%0*d' 800 0)
> +packet3="${eth}${ip3}${addrs}${data3}"
> +AT_CHECK([ovs-appctl netdev-dummy/receive p90 "$packet3"])
> +
> +AT_CHECK([ovs-appctl dpctl/ipf-get-status -m \
> +| grep -E 'num frag:|v4 frags accepted:|v4 frags completed:|v4 frags beyond
> last:'], [], [dnl
> + num frag: 0
> + v4 frags accepted: 2
> + v4 frags completed: 2
> + v4 frags beyond last: 1
> +])
> +
> +OVS_VSWITCHD_STOP
> +AT_CLEANUP
> +
> +AT_SETUP([ofproto-dpif - fragment handling - reject fragment beyond last,
> last seen second])
> +OVS_VSWITCHD_START
> +add_of_ports br0 1 90
> +
> +AT_DATA([flows.txt], [dnl
> +table=0 in_port=90,ip actions=ct(commit),output:1
> +])
> +AT_CHECK([ovs-ofctl -O OpenFlow11 replace-flows br0 flows.txt])
> +
> +AT_CHECK([ovs-appctl dpctl/ipf-set-min-frag v4 400], [], [dnl
> +setting minimum fragment size successful
> +])
> +
> +dnl First admit a non-last fragment carrying bytes 800..1199 (MF set), then
> +dnl reject a last (MF=0) fragment carrying bytes 400..799, whose end lies
> +dnl before the already queued fragment and so leaves data beyond the last.
> +eth="50 54 00 00 00 0a 50 54 00 00 00 09 08 00"
> +addrs="0a 01 01 01 0a 01 01 02"
> +
> +dnl Packet 1 (admitted). Fragment carrying bytes 800..1199 (MF set).
> +dnl Ethernet II, Src: 50:54:00:00:00:09, Dst: 50:54:00:00:00:0a
> +dnl Type: IPv4 (0x0800)
> +dnl Internet Protocol Version 4, Src: 10.1.1.1, Dst: 10.1.1.2
> +dnl 0100 .... = Version: 4
> +dnl .... 0101 = Header Length: 20 bytes (5)
> +dnl Differentiated Services Field: 0x00 (DSCP: CS0, ECN: Not-ECT)
> +dnl Total Length: 420
> +dnl Identification: 0x0020 (32)
> +dnl 001. .... = Flags: 0x1 (More fragments)
> +dnl ...0 0000 0110 0100 = Fragment Offset: 800
> +dnl Time to Live: 64
> +dnl Protocol: UDP (17)
> +dnl Header Checksum: 0x42c1
> +dnl Data (400 bytes)
> +ip1="45 00 01 a4 00 20 20 64 40 11 42 c1"
> +data1=$(printf '%0*d' 800 0)
> +packet1="${eth}${ip1}${addrs}${data1}"
> +
> +dnl Packet 2 (rejected as beyond last). Last fragment carrying bytes
> +dnl 400..799 (MF clear), ending before packet 1.
> +dnl Ethernet II, Src: 50:54:00:00:00:09, Dst: 50:54:00:00:00:0a
> +dnl Type: IPv4 (0x0800)
> +dnl Internet Protocol Version 4, Src: 10.1.1.1, Dst: 10.1.1.2
> +dnl 0100 .... = Version: 4
> +dnl .... 0101 = Header Length: 20 bytes (5)
> +dnl Differentiated Services Field: 0x00 (DSCP: CS0, ECN: Not-ECT)
> +dnl Total Length: 420
> +dnl Identification: 0x0020 (32)
> +dnl 000. .... = Flags: 0x0 (Last fragment)
> +dnl ...0 0000 0011 0010 = Fragment Offset: 400
> +dnl Time to Live: 64
> +dnl Protocol: UDP (17)
> +dnl Header Checksum: 0x62f3
> +dnl Data (400 bytes)
> +ip2="45 00 01 a4 00 20 00 32 40 11 62 f3"
> +data2=$(printf '%0*d' 800 0)
> +packet2="${eth}${ip2}${addrs}${data2}"
> +
> +AT_CHECK([ovs-appctl netdev-dummy/receive p90 "$packet1"])
> +AT_CHECK([ovs-appctl netdev-dummy/receive p90 "$packet2"])
> +
> +AT_CHECK([ovs-appctl dpctl/ipf-get-status -m \
> +| grep -E 'num frag:|v4 frags accepted:|v4 frags completed:|v4 frags beyond
> last:'], [], [dnl
> + num frag: 1
> + v4 frags accepted: 1
> + v4 frags completed: 0
> + v4 frags beyond last: 1
> +])
> +
> +OVS_VSWITCHD_STOP
> +AT_CLEANUP
> +
> +AT_SETUP([ofproto-dpif - fragment handling - reject fragment beyond last -
> IPv6])
> +OVS_VSWITCHD_START
> +add_of_ports br0 1 90
> +
> +AT_DATA([flows.txt], [dnl
> +table=0 in_port=90,ipv6 actions=ct(commit),output:1
> +])
> +AT_CHECK([ovs-ofctl -O OpenFlow11 replace-flows br0 flows.txt])
> +
> +AT_CHECK([ovs-appctl dpctl/ipf-set-min-frag v6 400], [], [dnl
> +setting minimum fragment size successful
> +])
> +
> +dnl First admit a last fragment carrying bytes 400..799 (M clear), then
> reject
> +dnl a new fragment carrying bytes 800..1199 (M set), whose data lies beyond
> the
> +dnl end of the last fragment. The IPv6 fragment header holds the next header
> +dnl (UDP), the fragment offset in 8-byte units with the M flag, and the
> +dnl identification.
> +dnl Ethernet II, Src: 50:54:00:00:00:09, Dst: 50:54:00:00:00:0a
> +dnl Type: IPv6 (0x86dd)
> +dnl Internet Protocol Version 6, Src: 2001:db8::1, Dst: 2001:db8::2
> +dnl 0110 .... = Version: 6
> +dnl Payload Length: 408
> +dnl Next Header: Fragment Header for IPv6 (44)
> +dnl Hop Limit: 64
> +eth="50 54 00 00 00 0a 50 54 00 00 00 09 86 dd"
> +ip6="60 00 00 00 01 98 2c 40 dnl
> +20 01 0d b8 00 00 00 00 00 00 00 00 00 00 00 01 dnl
> +20 01 0d b8 00 00 00 00 00 00 00 00 00 00 00 02"
> +
> +dnl Packet 1 (admitted). Last fragment carrying bytes 400..799 (M clear).
> +dnl Fragment Header for IPv6
> +dnl Next Header: UDP (17)
> +dnl Reserved: 0x00
> +dnl 0000 0001 1001 0... = Offset: 400 (0x190)
> +dnl .... .... .... .000 = Reserved bits / M flag: 0 (last fragment)
> +dnl Identification: 0x00000020
> +dnl Data (400 bytes)
> +frag1="11 00 01 90 00 00 00 20"
> +data1=$(printf '%0*d' 800 0)
> +packet1="${eth}${ip6}${frag1}${data1}"
> +
> +dnl Packet 2 (rejected as beyond last). Fragment carrying bytes 800..1199
> +dnl (M set), starting past packet 1's last-fragment end.
> +dnl Fragment Header for IPv6
> +dnl Next Header: UDP (17)
> +dnl Reserved: 0x00
> +dnl 0000 0011 0010 0... = Offset: 800 (0x320)
> +dnl .... .... .... .001 = More Fragments: 1
> +dnl Identification: 0x00000020
> +dnl Data (400 bytes)
> +frag2="11 00 03 21 00 00 00 20"
> +data2=$(printf '%0*d' 800 0)
> +packet2="${eth}${ip6}${frag2}${data2}"
> +
> +AT_CHECK([ovs-appctl netdev-dummy/receive p90 "$packet1"])
> +AT_CHECK([ovs-appctl netdev-dummy/receive p90 "$packet2"])
> +
> +AT_CHECK([ovs-appctl dpctl/ipf-get-status -m \
> +| grep -E 'num frag:|v6 frags accepted:|v6 frags completed:|v6 frags beyond
> last:'], [], [dnl
> + num frag: 1
> + v6 frags accepted: 1
> + v6 frags completed: 0
> + v6 frags beyond last: 1
> +])
> +
> +OVS_VSWITCHD_STOP
> +AT_CLEANUP
> +
> +dnl IPF_DUP_FRAG(FLAGS_OFFSET, CSUM)
> +dnl
> +dnl Expands to an IPv4 UDP fragment 10.1.1.1 -> 10.1.1.2, ID 0x0021, total
> +dnl length 420 (400 zero data bytes), with the given 16-bit flags/fragment
> +dnl offset field and header checksum, both in hex.
> +m4_define([IPF_DUP_FRAG],
> + [50540000000a5054000000090800450001a40021$1[]4011$2[]0a0101010a010102[]dnl
> +m4_for([i], [1], [400], [1], [00])])
> +
> +AT_SETUP([ofproto-dpif - fragment handling - last duplicate of middle
> fragment])
> +OVS_VSWITCHD_START
> +add_of_ports --pcap br0 1 90
> +
> +AT_DATA([flows.txt], [dnl
> +table=0 in_port=90,ip actions=ct(commit),output:1
> +])
> +AT_CHECK([ovs-ofctl -O OpenFlow11 replace-flows br0 flows.txt])
> +
> +AT_CHECK([ovs-appctl dpctl/ipf-set-min-frag v4 400], [], [dnl
> +setting minimum fragment size successful
> +])
> +
> +dnl Bytes 0..399, MF set.
> +AT_CHECK([ovs-appctl netdev-dummy/receive p90 "IPF_DUP_FRAG([2000],
> [4324])"])
> +dnl Bytes 400..799, MF set.
> +AT_CHECK([ovs-appctl netdev-dummy/receive p90 "IPF_DUP_FRAG([2032],
> [42f2])"])
> +dnl Bytes 800..1199, MF set.
> +AT_CHECK([ovs-appctl netdev-dummy/receive p90 "IPF_DUP_FRAG([2064],
> [42c0])"])
> +dnl Bytes 400..799, MF clear: duplicate of the middle fragment. Queued data
> +dnl lies past it, so it is dropped without marking the stored copy as last.
> +AT_CHECK([ovs-appctl netdev-dummy/receive p90 "IPF_DUP_FRAG([0032],
> [62f2])"])
> +dnl Bytes 1200..1599, MF clear: the real last fragment, completes the
> datagram.
> +AT_CHECK([ovs-appctl netdev-dummy/receive p90 "IPF_DUP_FRAG([0096],
> [628e])"])
> +
> +AT_CHECK([ovs-appctl dpctl/ipf-get-status -m \
> +| grep -E 'num frag:|v4 frags accepted:|v4 frags completed:|v4 frags
> duplicate:|v4 frags beyond last:'], [], [dnl
> + num frag: 0
> + v4 frags accepted: 4
> + v4 frags completed: 4
> + v4 frags duplicate: 1
> + v4 frags beyond last: 0
> +])
> +
> +dnl The four original fragments are forwarded in offset order.
> +AT_CHECK([ovs-pcap p1-tx.pcap], [0], [dnl
> +IPF_DUP_FRAG([2000], [4324])
> +IPF_DUP_FRAG([2032], [42f2])
> +IPF_DUP_FRAG([2064], [42c0])
> +IPF_DUP_FRAG([0096], [628e])
> +])
> +
> +OVS_VSWITCHD_STOP
> +AT_CLEANUP
> +
> +AT_SETUP([ofproto-dpif - fragment handling - last fragment arrives as
> duplicate])
> +OVS_VSWITCHD_START
> +add_of_ports --pcap br0 1 90
> +
> +AT_DATA([flows.txt], [dnl
> +table=0 in_port=90,ip actions=ct(commit),output:1
> +])
> +AT_CHECK([ovs-ofctl -O OpenFlow11 replace-flows br0 flows.txt])
> +
> +AT_CHECK([ovs-appctl dpctl/ipf-set-min-frag v4 400], [], [dnl
> +setting minimum fragment size successful
> +])
> +
> +dnl Bytes 0..399, MF set.
> +AT_CHECK([ovs-appctl netdev-dummy/receive p90 "IPF_DUP_FRAG([2000],
> [4324])"])
> +dnl Bytes 400..799, MF set.
> +AT_CHECK([ovs-appctl netdev-dummy/receive p90 "IPF_DUP_FRAG([2032],
> [42f2])"])
> +dnl Bytes 400..799, MF clear: duplicate of the second fragment that completes
> +dnl the datagram. It replaces the stored MF=1 copy.
> +AT_CHECK([ovs-appctl netdev-dummy/receive p90 "IPF_DUP_FRAG([0032],
> [62f2])"])
> +
> +AT_CHECK([ovs-appctl dpctl/ipf-get-status -m \
> +| grep -E 'num frag:|v4 frags accepted:|v4 frags completed:|v4 frags
> duplicate:'], [], [dnl
> + num frag: 0
> + v4 frags accepted: 2
> + v4 frags completed: 2
> + v4 frags duplicate: 1
> +])
> +
> +dnl The first fragment and the MF=0 copy of the second are forwarded, so the
> +dnl receiver gets a last fragment.
> +AT_CHECK([ovs-pcap p1-tx.pcap], [0], [dnl
> +IPF_DUP_FRAG([2000], [4324])
> +IPF_DUP_FRAG([0032], [62f2])
> +])
> +
> +OVS_VSWITCHD_STOP
> +AT_CLEANUP
> +
> AT_SETUP([ofproto-dpif - handling of malformed TCP packets])
> OVS_VSWITCHD_START
> add_of_ports br0 1 90
> diff --git a/tests/system-userspace-macros.at
> b/tests/system-userspace-macros.at
> index 1358d7156..20e9ce475 100644
> --- a/tests/system-userspace-macros.at
> +++ b/tests/system-userspace-macros.at
> @@ -182,6 +182,7 @@ AT_CHECK([ovs-appctl dpctl/ipf-get-status], [], [dnl
> v4 frags overlapped: 0
> v4 frags duplicate: 0
> v4 frags discarded: 0
> + v4 frags beyond last: 0
> v4 frags purged: 0
> min v6 frag size: 1280
> v6 frags accepted: 0
> @@ -192,6 +193,7 @@ AT_CHECK([ovs-appctl dpctl/ipf-get-status], [], [dnl
> v6 frags overlapped: 0
> v6 frags duplicate: 0
> v6 frags discarded: 0
> + v6 frags beyond last: 0
> v6 frags purged: 0
> ])
> ])
> @@ -218,6 +220,7 @@ AT_CHECK([ovs-appctl dpctl/ipf-get-status --more], [],
> [dnl
> v4 frags overlapped: 0
> v4 frags duplicate: 0
> v4 frags discarded: 0
> + v4 frags beyond last: 0
> v4 frags purged: 0
> min v6 frag size: 1280
> v6 frags accepted: 0
> @@ -228,6 +231,7 @@ AT_CHECK([ovs-appctl dpctl/ipf-get-status --more], [],
> [dnl
> v6 frags overlapped: 0
> v6 frags duplicate: 0
> v6 frags discarded: 0
> + v6 frags beyond last: 0
> v6 frags purged: 0
>
> Fragment Lists:
> @@ -257,6 +261,7 @@ AT_CHECK([ovs-appctl dpctl/ipf-get-status --more], [],
> [dnl
> v4 frags overlapped: 0
> v4 frags duplicate: 0
> v4 frags discarded: 0
> + v4 frags beyond last: 0
> v4 frags purged: 0
> min v6 frag size: 1280
> v6 frags accepted: 30
> @@ -267,6 +272,7 @@ AT_CHECK([ovs-appctl dpctl/ipf-get-status --more], [],
> [dnl
> v6 frags overlapped: 0
> v6 frags duplicate: 0
> v6 frags discarded: 0
> + v6 frags beyond last: 0
> v6 frags purged: 0
>
> Fragment Lists:
> @@ -303,6 +309,7 @@ AT_CHECK([ovs-appctl dpctl/ipf-get-status -m |
> FORMAT_FRAG_LIST()], [], [dnl
> v4 frags overlapped: 0
> v4 frags duplicate: 0
> v4 frags discarded: 0
> + v4 frags beyond last: 0
> v4 frags purged: 0
> min v6 frag size: 1280
> v6 frags accepted: 0
> @@ -313,6 +320,7 @@ AT_CHECK([ovs-appctl dpctl/ipf-get-status -m |
> FORMAT_FRAG_LIST()], [], [dnl
> v6 frags overlapped: 0
> v6 frags duplicate: 0
> v6 frags discarded: 0
> + v6 frags beyond last: 0
> v6 frags purged: 0
>
> Fragment Lists:
_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev