Conversation
| std::string vlan = kfvKey(entry); | ||
| std::vector<swss::FieldValueTuple> fieldValues = kfvFieldsValues(entry); | ||
|
|
||
| for (auto &fieldValue: fieldValues) { |
There was a problem hiding this comment.
we need to check the operation here if it is ADD/DEL
There was a problem hiding this comment.
The dhcpv6 server address are type string value. e.g.: "fc02:2000::1,fc02:2000::2"
HDEL would delete the entire string of addresses. HSET updates the list of server addresses.
When config_db updates the list of server addresses, all addresses are properly fetched and processed regardless new addresses are added/deleted. Therefore, I don't think there is a need to check for add/del
There was a problem hiding this comment.
You can get the operation using std::string operation = kfvOp(entry);. This way we can tell the type of the record updates. I think they are SET/DEL operation.
src/dhcp6relay/src/relay.cpp
Outdated
| addr[0] = 0; | ||
|
|
||
| if (getifaddrs(&ifa) == -1) { | ||
| syslog(LOG_WARNING, "getifaddrs: Unable to get network interfaces\n"); |
There was a problem hiding this comment.
nit: use spaces only for indentation
src/dhcp6relay/src/relay.cpp
Outdated
| auto dhcp_header = parse_dhcpv6_hdr(current_position); | ||
|
|
||
| if ((ntohs(udp_header->dest)) == 547 ) { | ||
| if(dhcp_header->msg_type == SOLICIT || REQUEST || CONFIRM || RENEW || REBIND || RELEASE || DECLINE) { |
There was a problem hiding this comment.
what is meant by this condition? this is true all the time
There was a problem hiding this comment.
Thanks for catching. Fixed.
src/dhcp6relay/src/relay.cpp
Outdated
| * @return none | ||
| */ | ||
| void listen_server(relay_config *config) { | ||
| while (serverListener) { |
There was a problem hiding this comment.
why the server listener is not part of the even loop?
There was a problem hiding this comment.
Added server listener to libevent
src/dhcp6relay/src/relay.cpp
Outdated
| if(dhcp_header->msg_type == SOLICIT || REQUEST || CONFIRM || RENEW || REBIND || RELEASE || DECLINE) { | ||
| relay_client(config->local_sock, current_position, ntohs(udp_header->len) - sizeof(udphdr), ip_header, ether_header, config); | ||
| } | ||
| if (((ntohs(udp_header->dest)) == RELAY_PORT) && (dhcp_header->msg_type == SOLICIT || REQUEST || CONFIRM || RENEW || REBIND || RELEASE || DECLINE)) { |
There was a problem hiding this comment.
This condition will always be true:
(dhcp_header->msg_type == SOLICIT || REQUEST || CONFIRM || RENEW || REBIND || RELEASE || DECLINE)
src/dhcp6relay/debian/rules
Outdated
| @@ -0,0 +1,7 @@ | |||
| #!/usr/bin/make -f | |||
|
|
|||
| DEB_CFLAGS_APPEND=-std=gnu11 | |||
There was a problem hiding this comment.
you can add this flag to CFLAGS in Makefile above.
|
|
||
| constexpr auto DEFAULT_TIMEOUT_MSEC = 1000; | ||
|
|
||
| bool mPollSwssNotifcation = true; |
There was a problem hiding this comment.
you can drop the letter m as it is normally used to indicate class member.
| void handleSwssNotification(arg_config *context) | ||
| { | ||
| std::shared_ptr<swss::DBConnector> configDbPtr = std::make_shared<swss::DBConnector> ("CONFIG_DB", 0); | ||
| swss::SubscriberStateTable ipHelpersTable(configDbPtr.get(), "DHCP"); |
There was a problem hiding this comment.
We need to add DHCP as a table name in schema.h file.
| while (ss.good()) { | ||
| std::string substr; | ||
| getline(ss, substr, ','); | ||
| if(substr == "79") |
There was a problem hiding this comment.
is the option 79 name up-to-date?
src/dhcp6relay/src/configInterface.h
Outdated
| #include "select.h" | ||
| #include "relay.h" | ||
|
|
||
| void initialize_swss(arg_config *context); |
There was a problem hiding this comment.
please add doxygen comments to functions in this file.
src/dhcp6relay/src/relay.cpp
Outdated
|
|
||
| ifa_tmp = ifa; | ||
| while (ifa_tmp) { | ||
| if ((ifa_tmp->ifa_addr) && (ifa_tmp->ifa_addr->sa_family == AF_INET6)) { |
There was a problem hiding this comment.
please remove tabs and use 4 spaces indentation.
src/dhcp6relay/src/main.cpp
Outdated
| } | ||
| catch (std::exception &e) | ||
| { | ||
| printf("Usage: -i <interface> -o <option>\n"); |
There was a problem hiding this comment.
nit: we are not using cli args anymore.
src/dhcp6relay/src/relay.h
Outdated
| /* DHCPv6 filter */ | ||
| /* sudo tcpdump -dd "ip6 dst ff02::1:2 && udp dst port 547" */ | ||
|
|
||
| static struct sock_filter ether_relay_filter[] = { |
There was a problem hiding this comment.
please move this static variable to .c file
src/dhcp6relay/src/relay.cpp
Outdated
|
|
||
| ifa_tmp = ifa; | ||
| while (ifa_tmp) { | ||
| if ((ifa_tmp->ifa_addr) && (ifa_tmp->ifa_addr->sa_family == AF_INET6)) { |
There was a problem hiding this comment.
please remove tabs and use 4 spaces indentation.
src/dhcp6relay/src/relay.cpp
Outdated
| * @return none | ||
| */ | ||
| void relay_relay_reply(int sock, const uint8_t *msg, int32_t len, relay_config *configs) { | ||
| uint8_t buffer[4096]; |
There was a problem hiding this comment.
can you please avoid having large local vars?
* Added DHCPv6 Relay * Added DHCPv6 Counter (cherry picked from commit f0e640f)
* Added DHCPv6 Relay * Added DHCPv6 Counter
* Added DHCPv6 Relay * Added DHCPv6 Counter
* Added DHCPv6 Relay * Added DHCPv6 Counter
DHCPv6 is a network protocol used to assign IPv6 addresses and provide configuration for devices to communicate on a network. DHCPv6 relay agent helps forwards DHCP packets between clients and servers that do not reside on a shared physical subnet, so that all subnets can share DHCPv6 server, and DHCPv6 server is not required on every LAN. This DHCPv6 relay agent supports option 79 which incorporates the client link-layer address in Relay-Forward messages that is sent to the server, which is needed by the server to allow IPv6 reservation to clients based on their physical MAC addresses.
This PR is part of: sonic-net/SONiC#787
Signed-off-by: Kelly Yeh [email protected]
Why I did it
To support option 79 in DHCPv6.
How I did it
Implemented DHCPv6 operations along with option 79.
Read from config_db to process dhcpv6 server addresses and options.
How to verify it
Build the binary with Makefile and run it on switch with IPv6 configured and DHCPv6 server support
Which release branch to backport (provide reason below if selected)
Description for the changelog
A picture of a cute animal (not mandatory but encouraged)