Skip to content

[PWCI] "[ovs-dev] netdev-native-tnl: Fix DF bit not being extracted into tunnel flags."#12

Open
ovsrobot wants to merge 1 commit intomainfrom
series_472781
Open

[PWCI] "[ovs-dev] netdev-native-tnl: Fix DF bit not being extracted into tunnel flags."#12
ovsrobot wants to merge 1 commit intomainfrom
series_472781

Conversation

@ovsrobot
Copy link
Owner

@ovsrobot ovsrobot commented Sep 8, 2025

NOTE: This is an auto submission for "[ovs-dev] netdev-native-tnl: Fix DF bit not being extracted into tunnel flags.".

See "http://patchwork.ozlabs.org/project/openvswitch/list/?series=472781" for details.

Summary by Sourcery

Improve tunnel metadata parsing by correctly handling the IPv4 DF bit and preserving existing flags when setting the GRE checksum flag, and update tests accordingly

Bug Fixes:

  • Extract the IPv4 DF bit into the tunnel flags when parsing packet metadata
  • Combine the GRE checksum flag with existing flags instead of overwriting them

Tests:

  • Update tunnel-related tests to reflect the new flag extraction and merging behavior

Summary by CodeRabbit

  • New Features
    • More accurate propagation of inner IP “Don’t Fragment” intent into tunnel metadata.
  • Bug Fixes
    • Preserve existing tunnel flags when marking checksum support, avoiding accidental flag overrides.
    • Correct DF and checksum flag handling for GRE/Geneve tunnels to reflect actual packet headers.
  • Tests
    • Updated expected flow dumps and traces (NSH, packet-type-aware, tunnel push/pop) to show +df-csum+key where applicable.
    • Shifted MPLS expectations to packet_type-aware representation.
    • Adjusted recirculation and tunnel descriptors in outputs for consistency.

OVS adds matches on the DF/CSUM/etc bits of the tunnel info flags, but
the DF bit is never actually extracted from the outer IP header during
the tunnel decapsulation.  This is not a huge problem, as we'll only
match on what was parsed out, since matching on DF flag is not exposed
through OpenFlow to the users.  And since the bit is never extracted,
we'll just always match on -df, which sort of "works", because the bit
is never extracted and so it is never set.  However, this causes
misleading -df matches in the datapath flow dumps even if the packets
actually have the DF bit set, which it is by default.

Fix that by actually extracting the bit from the outer header while
decapsulating tunneled traffic.

Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
Signed-off-by: 0-day Robot <robot@bytheb.org>
@sourcery-ai
Copy link

sourcery-ai bot commented Sep 8, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

This patch enriches tunnel metadata extraction to capture the IP "Don't Fragment" bit and fixes GRE checksum flag handling by accumulating flags rather than overwriting them, with corresponding updates to tunnel-related test fixtures.

Sequence diagram for tunnel metadata extraction with DF bit

sequenceDiagram
    participant Packet as "dp_packet"
    participant IPHeader as "ip"
    participant TunnelMD as "flow_tnl"
    Packet->>IPHeader: Parse IP header
    IPHeader->>TunnelMD: Provide ip_tos, ip_ttl
    IPHeader->>TunnelMD: Provide ip_frag_off
    alt DF bit set
        TunnelMD->>TunnelMD: Set FLOW_TNL_F_DONT_FRAGMENT flag
    end
Loading

Sequence diagram for GRE header parsing with cumulative flags

sequenceDiagram
    participant Packet as "dp_packet"
    participant TunnelMD as "flow_tnl"
    Packet->>TunnelMD: Parse GRE header
    alt GRE checksum present
        TunnelMD->>TunnelMD: Add FLOW_TNL_F_CSUM to flags
    end
Loading

Class diagram for updated tunnel metadata extraction

classDiagram
    class flow_tnl {
        +ip_tos
        +ip_ttl
        +flags
    }
    class dp_packet
    class ip {
        +ip_tos
        +ip_ttl
        +ip_frag_off
        +ip_ihl_ver
    }
    flow_tnl <.. dp_packet : extracted from
    flow_tnl <.. ip : extracted from
    flow_tnl : +FLOW_TNL_F_DONT_FRAGMENT
    flow_tnl : +FLOW_TNL_F_CSUM
Loading

File-Level Changes

Change Details Files
Support extracting IP "Don't Fragment" flag into tunnel metadata
  • Check the IP_DF bit in the frag_off field
  • Set FLOW_TNL_F_DONT_FRAGMENT via bitwise OR
  • Adjust header length accounting accordingly
lib/netdev-native-tnl.c
Correct GRE checksum flag accumulation
  • Change tnl->flags assignment to OR assignment for FLOW_TNL_F_CSUM
lib/netdev-native-tnl.c
Update tunnel-related tests to reflect metadata changes
  • Regenerate nsh.at test
  • Regenerate packet-type-aware.at test
  • Regenerate tunnel-push-pop.at test
tests/nsh.at
tests/packet-type-aware.at
tests/tunnel-push-pop.at

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@coderabbitai
Copy link

coderabbitai bot commented Sep 8, 2025

Walkthrough

Updates tunnel metadata parsing in lib/netdev-native-tnl.c to propagate inner IPv4 DF intent and preserve existing flags when setting GRE checksum. Adjusts multiple test expectations to reflect +df-csum+key tunnel flags, revised tunnel/recirc representations, and packet_type/MPLS semantics.

Changes

Cohort / File(s) Summary of Changes
Tunnel metadata parsing
lib/netdev-native-tnl.c
Set FLOW_TNL_F_DONT_FRAGMENT when inner IPv4 DF is set; change GRE checksum handling from assignment to OR to preserve existing tunnel flags.
NSH tests
tests/nsh.at
Update expected traces/flow-dumps: tunnel(...) descriptors replace some recirc forms; flags switch to +df-csum+key; remove nsh_c1 in MD1/MD2 traces where applicable; adjust in_port (e.g., 4789).
Packet-type-aware tests
tests/packet-type-aware.at
Revise expected outputs for packet_type-aware behavior: DF flag becomes +df-csum; MPLS flows use packet_type(ns=1,id=0x8847); adjust encapsulation paths and outputs in several sections.
Tunnel push/pop tests
tests/tunnel-push-pop.at
Change expected Geneve tunnel flags from -df-csum+key to +df-csum+key in dumped flow.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Pre-merge checks (1 passed, 1 warning, 1 inconclusive)

❌ Failed Checks (1 warning, 1 inconclusive)
Check Name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Description Check ❓ Inconclusive While the description includes a Sourcery-generated summary and links to external patch details, it relies on an out-of-repo link for rationale and lacks an in-PR motivation, test plan specifics, and details on how to validate the changes. Expand the description to include the reasoning behind extracting the DF bit, outline the in-PR testing steps and expected outcomes, and consider adding a repository-level pull request template to ensure all context and validation criteria are consistently documented.
✅ Passed Checks (1 passed)
Check Name Status Explanation
Title Check ✅ Passed The title accurately captures the primary change—fixing the DF bit extraction into tunnel flags in netdev-native-tnl—and is directly relevant to the diff summary.

Poem

A rabbit taps keys with a gentle thrum,
Flags hop from minus to plus—here they come! 🐇
DF set, CSUM kept, tunnels align,
Tests now echo the updated sign.
In packets and paths, the burrows are neat—
Carrots for code that’s clean and complete. 🥕

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Example:

reviews:
  pre_merge_checks:
    custom_checks:
		  - name: "Undocumented Breaking Changes"
			  mode: "warning"
			  instructions: |
				  Flag potential breaking changes that are not documented:
				  1. Identify changes to public APIs/exports, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints (including removed/renamed items and changes to types, required params, return values, defaults, or behavior).
				  2. Ignore purely internal/private changes (e.g., code not exported from package entry points or marked internal).
				  3. Verify documentation exists: a "Breaking Change" section in the PR description and updates to CHANGELOG.md.

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9a2169a and 23f5dc4.

📒 Files selected for processing (4)
  • lib/netdev-native-tnl.c (2 hunks)
  • tests/nsh.at (2 hunks)
  • tests/packet-type-aware.at (8 hunks)
  • tests/tunnel-push-pop.at (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
lib/netdev-native-tnl.c (1)
include/sparse/netinet/in.h (1)
  • htons (158-161)
🔇 Additional comments (14)
tests/tunnel-push-pop.at (1)

688-688: Expectation update to flags(+df-csum+key) is correct.

Matches new DF extraction and preserved CSUM semantics on tunnel metadata.

lib/netdev-native-tnl.c (2)

155-157: Correctly propagates IPv4 DF into tunnel flags.

Setting FLOW_TNL_F_DONT_FRAGMENT when IP_DF is set fixes the missing DF metadata.


474-476: Preserve existing tunnel flags when GRE CSUM is present
Using |= correctly avoids clobbering previously set DF/KEY flags; no plain = assignments to tnl->flags remain.

tests/nsh.at (2)

722-724: Updated tunnel() expectations to +df-csum+key look right.

Aligned with DF extraction and CSUM preservation after decap.


776-779: Consistent +df-csum+key flags across recirc path.

Keeps test outcomes in sync with parser behavior.

tests/packet-type-aware.at (9)

327-327: DF and CSUM flags correctly propagated into tunnel metadata.

Expectation updated to flags(+df-csum) matches the fix (DF extraction + preserving CSUM). Looks good.


345-345: Consistent +df-csum on GRE leg br-p1 <-> br-in2.

Matches the underlay DF bit in outer IPv4 and retained CSUM flag. Good.


363-363: +df-csum carried on return path.

Correctly mirrors the DF bit and CSUM on the reverse GRE flow.


381-382: Multi-hop recirc preserves +df-csum across both GRE segments.

Both transitional recircs show flags(+df-csum) as expected. Solid.


400-401: Switch to L3 packet_type namespace is correct.

Using packet_type(ns=1,id=0x800) for IPv4 and explicitly push_eth when egressing to L2 aligns with packet-type-aware semantics.


419-419: DF/CSUM expectation aligned on this tunnel leg.

flags(+df-csum) here is consistent with the rest of the GRE path expectations.


505-505: Drop on L3 packet without suitable egress handling is expected.

packet_type(ns=1,id=0x800) with actions:drop reflects the negative-path test. OK.


1018-1019: Correct MPLS packet_type semantics and recirc.

  • MPLS frames now use packet_type(ns=1,id=0x8847) at decap, then recirc to Ethernet (ns=0) for post-pop pipeline.
  • +df-csum preserved across both recirc entries.

Looks accurate.


327-327: All packet-type expectations are up to date
Ran repo checks: no remaining “-df-csum” flags, no MPLS or IPv4 using ns=0; 11 “+df-csum” tunnel flags confirmed.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch series_472781

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey there - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

ovsrobot pushed a commit that referenced this pull request Sep 19, 2025
When vport_add_channel() is called duplicate, the resources for previously
specified sock was not freed. This patch fixes this issue.

Reported by Address Sanitizer.

Direct leak of 60 byte(s) in 3 object(s) allocated from:
    #0 0xffffb3658080 in malloc (/usr/lib64/libasan.so.6+0xa9080)
    #1 0x922630 in xmalloc__ lib/util.c:141
    #2 0x922718 in xmalloc lib/util.c:176
    #3 0x9c67e4 in nl_sock_create lib/netlink-socket.c:147
    #4 0x94cb6c in create_nl_sock lib/dpif-netlink.c:283
    #5 0x950bec in dpif_netlink_port_add__ lib/dpif-netlink.c:978
    #6 0x951a20 in dpif_netlink_port_add_compat lib/dpif-netlink.c:1101
    #7 0x951cd0 in dpif_netlink_port_add lib/dpif-netlink.c:1147
    #8 0x616354 in dpif_port_add lib/dpif.c:602
    #9 0x49f424 in port_add ofproto/ofproto-dpif.c:4144
    #10 0x44d51c in ofproto_port_add ofproto/ofproto.c:2204
    #11 0x416914 in iface_do_create vswitchd/bridge.c:2203
    #12 0x416dbc in iface_create vswitchd/bridge.c:2246
    #13 0x40e1d0 in bridge_add_ports__ vswitchd/bridge.c:1225
    #14 0x40e290 in bridge_add_ports vswitchd/bridge.c:1241
    #15 0x40cc6c in bridge_reconfigure vswitchd/bridge.c:952
    #16 0x420884 in bridge_run vswitchd/bridge.c:3440
    #17 0x42f3d0 in main vswitchd/ovs-vswitchd.c:137

Fixes: 69c5158 ("dpif-netlink: don't allocate per thread netlink sockets")
Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
Signed-off-by: 0-day Robot <robot@bytheb.org>
ovsrobot pushed a commit that referenced this pull request Oct 9, 2025
When vport_add_channel() is called duplicate, the resources for previously
specified sock was not freed. This patch fixes this issue.

Reported by Address Sanitizer.

Direct leak of 60 byte(s) in 3 object(s) allocated from:
    #0 0xffffb3658080 in malloc (/usr/lib64/libasan.so.6+0xa9080)
    #1 0x922630 in xmalloc__ lib/util.c:141
    #2 0x922718 in xmalloc lib/util.c:176
    #3 0x9c67e4 in nl_sock_create lib/netlink-socket.c:147
    #4 0x94cb6c in create_nl_sock lib/dpif-netlink.c:283
    #5 0x950bec in dpif_netlink_port_add__ lib/dpif-netlink.c:978
    #6 0x951a20 in dpif_netlink_port_add_compat lib/dpif-netlink.c:1101
    #7 0x951cd0 in dpif_netlink_port_add lib/dpif-netlink.c:1147
    #8 0x616354 in dpif_port_add lib/dpif.c:602
    #9 0x49f424 in port_add ofproto/ofproto-dpif.c:4144
    #10 0x44d51c in ofproto_port_add ofproto/ofproto.c:2204
    #11 0x416914 in iface_do_create vswitchd/bridge.c:2203
    #12 0x416dbc in iface_create vswitchd/bridge.c:2246
    #13 0x40e1d0 in bridge_add_ports__ vswitchd/bridge.c:1225
    #14 0x40e290 in bridge_add_ports vswitchd/bridge.c:1241
    #15 0x40cc6c in bridge_reconfigure vswitchd/bridge.c:952
    #16 0x420884 in bridge_run vswitchd/bridge.c:3440
    #17 0x42f3d0 in main vswitchd/ovs-vswitchd.c:137

Reproduce steps:
    ovs-vsctl add-br br-ovs
    ovs-vsctl add-port br-ovs test -- set interface test type=internal
    ip netns add ns_test
    ip link set test netns ns_test
    ip netns del ns_test
    ifconfig br-ovs up
    sleep 1
    ifconfig br-ovs down
    sleep 1
    ovs-vsctl del-br br-ovs

Fixes: 69c5158 ("dpif-netlink: don't allocate per thread netlink sockets")
Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
Signed-off-by: 0-day Robot <robot@bytheb.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants