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

[DHCP_RELAY] Updated wait_for_intf.sh to wait for ipv6 global and link local addr #12273

Merged
merged 5 commits into from
Oct 12, 2022

Conversation

vivekrnv
Copy link
Contributor

@vivekrnv vivekrnv commented Oct 5, 2022

Signed-off-by: Vivek Reddy Karri vkarri@nvidia.com

Why I did it

Fixes #11431

How I did it

dhcp6relay binds to ipv6 addresses configured on these vlan interfaces
Thus check if they are ready before launching dhcp6relay

How to verify it

  • Unit Tests
  • Tested on a live device
root@r-lionfish-16:/home/admin# redis-cli -n 4 hgetall "DHCP_RELAY|Vlan10"
1) "dhcpv6_servers@"
2) "fc01:2000::1"
root@r-lionfish-16:/home/admin# redis-cli -n 4 hgetall "VLAN|Vlan10"
1) "vlanid"
2) "10"
3) "dhcpv6_servers@"
4) "fc02:2000::1"
root@r-lionfish-16:/home/admin# ip addr show Vlan10
137: Vlan10@Bridge: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 9100 qdisc noqueue state UP group default qlen 1000
    link/ether 1c:34:da:1c:9f:00 brd ff:ff:ff:ff:ff:ff
    inet6 fc02:2000::2/24 scope global
       valid_lft forever preferred_lft forever
    inet6 fe80::1e34:daff:fe1c:9f00/64 scope link
       valid_lft forever preferred_lft forever
root@r-lionfish-16:/home/admin# systemctl restart dhcp_relay

Syslog:

Oct  4 03:41:44.255907 r-lionfish-16 INFO dhcp_relay#supervisord 2022-10-04 00:41:44,255 INFO spawned: 'start' with pid 18
Oct  4 03:41:44.256812 r-lionfish-16 INFO dhcp_relay#supervisord 2022-10-04 00:41:44,256 INFO success: start entered RUNNING state, process has stayed up for > than 0 seconds (startsecs)
Oct  4 03:41:44.269321 r-lionfish-16 INFO dhcp_relay#supervisord 2022-10-04 00:41:44,268 INFO exited: dhcpmon-Vlan10 (exit status 0; not expected)
Oct  4 03:41:44.504875 r-lionfish-16 INFO dhcp_relay#supervisord: start Waiting until interface Vlan10 is ready...
Oct  4 03:41:44.509125 r-lionfish-16 INFO dhcp_relay#supervisord: start Interface Vlan10 is ready!
Oct  4 03:41:44.509125 r-lionfish-16 INFO dhcp_relay#supervisord: start Waiting until interface Vlan10 has a link-local ipv6 address configured....
Oct  4 03:41:44.512623 r-lionfish-16 INFO dhcp_relay#supervisord: start Link-Local address is configured on Vlan10
root@r-lionfish-16:/home/admin# docker exec -it dhcp_relay cat /usr/bin/wait_for_intf.sh
#!/usr/bin/env bash
.............................

function check_for_ipv6_link_local
{
    IFACE_NAME=$1
    echo "Waiting until interface ${IFACE_NAME} has a link-local ipv6 address configured...."

    # Status of link local address is not populated in STATE_DB
    while true; do
        HAS_LL=$(ip -6 addr show ${IFACE_NAME} scope link 2> /dev/null)
        RC=$?
        if [[ ${RC} == "0" ]] && [[ ! -z ${HAS_LL} ]]; then
            break
        fi

        sleep 1
    done

    echo "Link-Local address is configured on ${IFACE_NAME}"
}

# dhcp6relay binds to ipv6 addresses configured on these vlan ifaces
# Thus check if they are ready before launching dhcp6relay
wait_until_iface_ready Vlan10 fc02:2000::2/24
check_for_ipv6_link_local Vlan10
..........

Negative Test: Remove link local address on Vlan iface and add it back

root@r-lionfish-16:/home/admin# ip addr del fe80::1e34:daff:fe1c:9f00/64 dev Vlan10
root@r-lionfish-16:/home/admin# ip addr show Vlan10
137: Vlan10@Bridge: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 9100 qdisc noqueue state UP group default qlen 1000
    link/ether 1c:34:da:1c:9f:00 brd ff:ff:ff:ff:ff:ff
    inet6 fc02:2000::2/24 scope global
       valid_lft forever preferred_lft forever
root@r-lionfish-16:/home/admin# systemctl restart dhcp_relay

root@r-lionfish-16:/home/admin# show logging -f | grep dhcp_relay
Oct  4 03:51:54.661081 r-lionfish-16 INFO dhcp_relay#supervisord 2022-10-04 00:51:54,659 INFO spawned: 'start' with pid 20
Oct  4 03:51:54.661081 r-lionfish-16 INFO dhcp_relay#supervisord 2022-10-04 00:51:54,660 INFO success: start entered RUNNING state, process has stayed up for > than 0 seconds (startsecs)
Oct  4 03:51:54.662736 r-lionfish-16 INFO dhcp_relay#supervisord 2022-10-04 00:51:54,662 INFO exited: dhcpmon-Vlan10 (exit status 0; not expected)
Oct  4 03:51:54.895207 r-lionfish-16 INFO dhcp_relay#supervisord: start Waiting until interface Vlan10 is ready...
Oct  4 03:51:54.899206 r-lionfish-16 INFO dhcp_relay#supervisord: start Interface Vlan10 is ready!
Oct  4 03:51:54.899535 r-lionfish-16 INFO dhcp_relay#supervisord: start Waiting until interface Vlan10 has a link-local ipv6 address configured....


root@r-lionfish-16:/home/admin# docker exec -it dhcp_relay supervisorctl status
dependent-startup                RUNNING   pid 12, uptime 0:01:20

root@r-lionfish-16:/home/admin# ip addr add fe80::1e34:daff:fe1c:9f00/64 dev Vlan10 scope link
root@r-lionfish-16:/home/admin#
Oct  4 03:54:37.641777 r-lionfish-16 INFO dhcp_relay#supervisord: start Link-Local address is configured on Vlan10
Oct  4 03:54:47.644881 r-lionfish-16 INFO dhcp_relay#supervisord 2022-10-04 00:54:47,644 INFO exited: start (exit status 0; expected)
Oct  4 03:54:48.674002 r-lionfish-16 INFO dhcp_relay#supervisord 2022-10-04 00:54:48,672 INFO spawned: 'dhcp6relay' with pid 539
Oct  4 03:54:48.683344 r-lionfish-16 DEBUG dhcp_relay#dhcp6relay: key: Vlan10, Operation: SET, f: dhcpv6_servers, v: fc01:2000::1
Oct  4 03:54:49.693668 r-lionfish-16 INFO dhcp_relay#supervisord 2022-10-04 00:54:49,692 INFO success: dhcp6relay entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
Oct  4 03:54:50.763750 r-lionfish-16 INFO dhcp_relay#supervisord 2022-10-04 00:54:50,762 INFO exited: dependent-startup (exit status 0; expected)

root@r-lionfish-16:/home/admin# docker exec -it dhcp_relay supervisorctl status
dependent-startup                EXITED    Oct 04 12:54 AM
dhcp-relay:dhcp6relay            RUNNING   pid 539, uptime 0:00:52
........
start                            EXITED    Oct 04 12:54 AM

Which release branch to backport (provide reason below if selected)

  • 201811
  • 201911
  • 202006
  • 202012
  • 202106
  • 202111
  • 202205

Description for the changelog

Link to config_db schema for YANG module changes

A picture of a cute animal (not mandatory but encouraged)

Signed-off-by: Vivek Reddy Karri <vkarri@nvidia.com>
Signed-off-by: Vivek Reddy Karri <vkarri@nvidia.com>
Signed-off-by: Vivek Reddy Karri <vkarri@nvidia.com>
Signed-off-by: Vivek Reddy Karri <vkarri@nvidia.com>
@vivekrnv vivekrnv requested a review from lguohan as a code owner October 5, 2022 02:23
@vivekrnv
Copy link
Contributor Author

vivekrnv commented Oct 5, 2022

/azpw run Azure.sonic-buildimage

@mssonicbld
Copy link
Collaborator

/AzurePipelines run Azure.sonic-buildimage

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@dgsudharsan
Copy link
Collaborator

@yxieca @kellyyeh Please review

@vivekrnv
Copy link
Contributor Author

/azpw run Azure.sonic-buildimage

@mssonicbld
Copy link
Collaborator

/AzurePipelines run Azure.sonic-buildimage

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@vivekrnv
Copy link
Contributor Author

/azpw run Azure.sonic-buildimage

@mssonicbld
Copy link
Collaborator

/AzurePipelines run Azure.sonic-buildimage

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@liat-grozovik liat-grozovik merged commit 34f9a64 into sonic-net:master Oct 12, 2022
qiluo-msft pushed a commit that referenced this pull request Oct 12, 2022
…k local addr (#12273)

- Why I did it
Fixes #11431

- How I did it
dhcp6relay binds to ipv6 addresses configured on these vlan interfaces
Thus check if they are ready before launching dhcp6relay

- How to verify it
Unit Tests
Tested on a live device

Signed-off-by: Vivek Reddy Karri <vkarri@nvidia.com>
@vivekrnv vivekrnv deleted the dhcp_relay_ipv6_check branch October 13, 2022 04:50
yxieca pushed a commit that referenced this pull request Oct 25, 2022
…k local addr (#12273)

- Why I did it
Fixes #11431

- How I did it
dhcp6relay binds to ipv6 addresses configured on these vlan interfaces
Thus check if they are ready before launching dhcp6relay

- How to verify it
Unit Tests
Tested on a live device

Signed-off-by: Vivek Reddy Karri <vkarri@nvidia.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[DHCP_RELAY] [IPv6] [202012] Failed to bind socket to link local ipv6 address
7 participants