Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interface-ID missing in A10-NSP DHCPv6 Relay Reply - RFC6221 #300

Closed
SoerenBusse opened this issue Jan 13, 2025 · 4 comments
Closed

Interface-ID missing in A10-NSP DHCPv6 Relay Reply - RFC6221 #300

SoerenBusse opened this issue Jan 13, 2025 · 4 comments
Assignees
Labels
bug Something isn't working fixed

Comments

@SoerenBusse
Copy link

Describe the bug
According to RFC6221, the DHCPv6 Relay Reply packet must contain the interface-id received by in relay-forw. https://datatracker.ietf.org/doc/html/rfc6221#section-5.3.2

However, when BNG Blaster acts as an A10-NSP with DHCPv6 NA/PD enabled, the relay-reply doesn't contain the interface-id. This triggers undefined behavior in access-nodes, like dropping the response or not decapsulating the relay-reply.

I think it's related to this code here, where the interface-id is not copied to the outer dhcpv6.
https://github.com/rtbrick/bngblaster/blob/main/code/bngblaster/src/bbl_a10nsp.c#L485

To Reproduce
Version (bngblaster -v):

Version: DEV
Compiler: GNU (11.4.0)
GIT:
  REF: dev
  SHA: b8e26058bb6a41af4c5716883be5701aede17646

Add any other context about the problem here.ON configuration:
Demo config from here, where BNGBlaster also acts an LDRA: #164

@SoerenBusse SoerenBusse added the bug Something isn't working label Jan 13, 2025
GIC-de added a commit that referenced this issue Jan 14, 2025
GIC-de added a commit that referenced this issue Jan 14, 2025
@GIC-de
Copy link
Member

GIC-de commented Jan 14, 2025

Please verify the following fix:
https://github.com/rtbrick/bngblaster/pull/301/files

@GIC-de GIC-de added the in-progress Work in progress label Jan 14, 2025
@SoerenBusse
Copy link
Author

Hi @GIC-de,

sadly this doesn't fix the issue:

Version: DEV
Compiler: GNU (14.2.1)
GIT:
  REF: HEAD
  SHA: fd3569650c300bb49228ea06abbf090e3581c1ef
IO Modes: packet_mmap_raw (default), packet_mmap, raw

I see the Interface-ID inside the relay-forw, but it's still missing in the relay-reply:
image
image

I've used the following config for testing:

{
    "interfaces": {
        "a10nsp": [
            {
                "__comment__": "DHCP Server",
                "interface": "veth1.1"
            }
        ],
        "access": [
            {
                "__comment__": "DHCP Client",
                "interface": "veth1.2",
                "type": "ipoe",
                "outer-vlan-min": 1,
                "outer-vlan-max": 4000,
                "inner-vlan": 7,
                "stream-group-id": 1
            }
        ]
    },
    "access-line": {
        "agent-remote-id": "DEU.RTBRICK.{session-global}",
        "agent-circuit-id": "0.0.0.0/0.0.0.0 eth 0:{session-global}",
        "rate-up": 1024,
        "rate-down": 50000
    },
    "dhcp": {
        "enable": true,
        "broadcast": false
    },
    "dhcpv6": {
        "enable": true,
        "ldra": true
    },
    "session-traffic": {
        "ipv4-pps": 1,
        "ipv6-pps": 1,
        "ipv6pd-pps": 1
    }
}

@SoerenBusse
Copy link
Author

SoerenBusse commented Jan 14, 2025

When stepping through with the debugger, the interface-id is correctly set on dhcpv6_outer, however it isn't sent on the wire.
image

Edit 1:
I think the root cause is here:
https://github.com/rtbrick/bngblaster/blob/main/code/bngblaster/src/bbl_protocols.c#L273
interface-id is not part of access-lines but rather an option in the DHCP Relay Root, therefore it needs to be encoded here.

Edit 2:
Adding the following to encode_dhcpv6 fixed the issue:

diff --git a/code/bngblaster/src/bbl_protocols.c b/code/bngblaster/src/bbl_protocols.c
index d8a5c01..d57c677 100644
--- a/code/bngblaster/src/bbl_protocols.c
+++ b/code/bngblaster/src/bbl_protocols.c
@@ -289,6 +289,15 @@ encode_dhcpv6(uint8_t *buf, uint16_t *len,
             memset(buf, 0x0, sizeof(ipv6addr_t));
         }
         BUMP_WRITE_BUFFER(buf, len, sizeof(ipv6addr_t));
+        /* Interface-ID */
+        if (dhcpv6->interface_id) {
+            *(uint16_t*)buf = htobe16(DHCPV6_OPTION_INTERFACE_ID);
+            BUMP_WRITE_BUFFER(buf, len, sizeof(uint16_t));
+            *(uint16_t*)buf = htobe16(dhcpv6->interface_id_len);
+            BUMP_WRITE_BUFFER(buf, len, sizeof(uint16_t));
+            memcpy(buf, dhcpv6->interface_id, dhcpv6->interface_id_len);
+            BUMP_WRITE_BUFFER(buf, len, dhcpv6->interface_id_len);
+        }
     } else {
         /* Type/Transaction ID */
         *(uint32_t*)buf = htobe32(dhcpv6->xid);

GIC-de added a commit that referenced this issue Jan 14, 2025
GIC-de added a commit that referenced this issue Jan 14, 2025
GIC-de added a commit that referenced this issue Jan 14, 2025
GIC-de added a commit that referenced this issue Jan 14, 2025
@GIC-de
Copy link
Member

GIC-de commented Jan 14, 2025

Please verify the solution here:
#302

GIC-de added a commit that referenced this issue Jan 14, 2025
@GIC-de GIC-de added fixed and removed in-progress Work in progress labels Jan 22, 2025
@GIC-de GIC-de mentioned this issue Jan 22, 2025
Merged
@GIC-de GIC-de closed this as completed in 38347aa Jan 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed
Projects
None yet
Development

No branches or pull requests

2 participants