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]: Add DHCP Relay Monitor #3886

Merged

Conversation

tahmed-dev
Copy link
Contributor

@tahmed-dev tahmed-dev commented Dec 12, 2019

DHCP relay MONitor (dhcpmon) keeps track of DORA messages. DORA is acronym for
Discover/Offer/Request/ACK DHCP messages which happen in succession for a
successful DHCP transaction. If DHCP Relay is detected to be not forwarding DORA
message, dhcpmon will log such event to syslog. Under the hood dhcpmon keeps
counts of clients DR messages, forwarded DR messages, DHCP server OA messages,
and forwarded OA messages. dhcpmon will check every 12 sec (configurable) if
counts are monotonically increasing and record snapshot of those counters.
dhcpmon will report discrepancies when detected between current counters and
snapshot counters.

pull-request: #3886
signed-off-by: Tamer Ahmed tamer.ahmed@microsoft.com

- What I did

- How I did it

- How to verify it

- Description for the changelog

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

Copy link
Contributor

@pavel-shirshov pavel-shirshov left a comment

Choose a reason for hiding this comment

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

Great work! Thank you!
I left some comments. I'll reread all *.c code in a few days. It's huge

dockers/docker-base-stretch/Dockerfile.j2 Outdated Show resolved Hide resolved
dockers/docker-base-stretch/Dockerfile.j2 Outdated Show resolved Hide resolved
src/dhcpmon/src/subdir.mk Outdated Show resolved Hide resolved
src/dhcpmon/src/dhcp_device.c Outdated Show resolved Hide resolved
src/dhcpmon/src/dhcp_device.c Outdated Show resolved Hide resolved
src/dhcpmon/src/dhcp_device.c Show resolved Hide resolved
src/dhcpmon/src/main.c Show resolved Hide resolved
@pavel-shirshov
Copy link
Contributor

Can you please update your description with DORA explanation?
Also, is it possible to avoid using threads here?

@tahmed-dev
Copy link
Contributor Author

tahmed-dev commented Dec 13, 2019

Can you please update your description with DORA explanation?
Will explain DORA in next upload. In the meantime, It is acronym for Discover/Offer/Request/ACK DHCP messages which happen in succession for a successful transaction.

Also, is it possible to avoid using threads here?
The call to any of libpcap capture routines' is a blocking call.

@pavel-shirshov
Copy link
Contributor

pavel-shirshov commented Dec 13, 2019

Put "DORA is acronym for Discover/Offer/Request/ACK DHCP messages. what happen in succession for a successful transaction." in the first post here. This would be enough.

You can skip using libpcap at all. Check here:
https://github.com/Azure/sonic-mgmt/blob/master/ansible/roles/test/files/helpers/ferret.py#L115
I create a socket with a filter. And then I use poll() to check many such sockets in one thread.

The filter compiled by tcpdump
https://github.com/Azure/sonic-mgmt/blob/master/ansible/roles/test/files/helpers/ferret.py#L263

Copy link
Contributor

@jleveque jleveque left a comment

Choose a reason for hiding this comment

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

Per comments. This PR is large, so like Pavel, I have just performed a cursory review. I plan to do more detailed review(s) in the coming days.

src/dhcpmon/src/dhcp_device.c Outdated Show resolved Hide resolved
src/dhcpmon/src/dhcp_mon.c Outdated Show resolved Hide resolved
src/dhcpmon/src/dhcp_device.h Outdated Show resolved Hide resolved
src/dhcpmon/src/main.c Outdated Show resolved Hide resolved
src/dhcpmon/src/dhcp_device.c Outdated Show resolved Hide resolved
@santoshdoke
Copy link

Just curious to know the motivation behind this DHCP relay monitor? Why do we need a separate monitor application to see if DHCP relay is working or not? Instead, can we add statistics support to DHCP relay itself?

Copy link
Contributor Author

@tahmed-dev tahmed-dev left a comment

Choose a reason for hiding this comment

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

@santoshdoke The motivation is to alert whenever DHCP relay is not healthy. There were situation where DHCP relay failed to forward DORA message. This is a mid-term solution to enable monitoring of DHCP Relay. In the meantime, we consider adding statistics to the relay agent as a long-term solution.

Just curious to know the motivation behind this DHCP relay monitor? Why do we need a separate monitor application to see if DHCP relay is working or not? Instead, can we add statistics support to DHCP relay itself?

@jleveque
Copy link
Contributor

jleveque commented Dec 16, 2019

Just curious to know the motivation behind this DHCP relay monitor? Why do we need a separate monitor application to see if DHCP relay is working or not? Instead, can we add statistics support to DHCP relay itself?

@santoshdoke: Ultimately, we want to push these statistics to the State DB. Our DB connector is written in C++ but the relay agent is written in C. Adding patches of this nature to the relay agent code would be tedious and ugly and could cause more issues in the long run. Since this is a separate utility, we can easily convert it to C++ and not need to patch an existing open-source project. Plus, a utility cannot properly monitor itself. It makes more sense to have a standalone monitor application.

dockers/docker-dhcp-relay/start.sh Outdated Show resolved Hide resolved
dockers/docker-base-stretch/Dockerfile.j2 Outdated Show resolved Hide resolved
src/dhcpmon/src/dhcp_devman.c Outdated Show resolved Hide resolved
src/dhcpmon/src/main.c Show resolved Hide resolved
src/dhcpmon/src/subdir.mk Outdated Show resolved Hide resolved
Copy link
Contributor

@pavel-shirshov pavel-shirshov left a comment

Choose a reason for hiding this comment

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

Good work!

Please check my comments.
Also check latest Joe's comments.

src/dhcpmon/src/main.c Show resolved Hide resolved
src/dhcpmon/src/dhcp_mon.c Outdated Show resolved Hide resolved
src/dhcpmon/src/dhcp_mon.c Outdated Show resolved Hide resolved
src/dhcpmon/src/dhcp_mon.c Outdated Show resolved Hide resolved
src/dhcpmon/src/dhcp_mon.h Outdated Show resolved Hide resolved
src/dhcpmon/src/dhcp_devman.c Show resolved Hide resolved
src/dhcpmon/src/dhcp_device.c Show resolved Hide resolved
src/dhcpmon/src/dhcp_device.c Outdated Show resolved Hide resolved
src/dhcpmon/src/dhcp_mon.c Outdated Show resolved Hide resolved
pavel-shirshov
pavel-shirshov previously approved these changes Dec 19, 2019
Copy link
Contributor

@pavel-shirshov pavel-shirshov left a comment

Choose a reason for hiding this comment

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

Please address Joe's comment

@pavel-shirshov
Copy link
Contributor

retest broadcom please

@jleveque
Copy link
Contributor

Retest vsimage please

pavel-shirshov
pavel-shirshov previously approved these changes Dec 20, 2019
DHCP relay MONitor (dhcpmon) keeps track of DORA messages. DORA is acronym for
Discover/Offer/Request/ACK DHCP messages which happen in succession for a
successful DHCP transaction. If DHCP Relay is detected to be not forwarding DORA
message, dhcpmon will log such event to syslog. Under the hood dhcpmon keeps
counts of clients DR messages, forwarded DR messages, DHCP server OA messages,
and forwarded OA messages. dhcpmon will check every 12 sec (configurable) if
counts are monotonically increasing and record snapshot of those counters.
dhcpmon will report discrepancies when detected between current counters and
snapshot counters.

This patch addresses code comments from pull request.

pull-request: sonic-net#3886
signed-off-by: Tamer Ahmed <tamer.ahmed@microsoft.com>
DHCP relay MONitor (dhcpmon) keeps track of DORA messages. DORA is acronym for
Discover/Offer/Request/ACK DHCP messages which happen in succession for a
successful DHCP transaction. If DHCP Relay is detected to be not forwarding DORA
message, dhcpmon will log such event to syslog. Under the hood dhcpmon keeps
counts of clients DR messages, forwarded DR messages, DHCP server OA messages,
and forwarded OA messages. dhcpmon will check every 12 sec (configurable) if
counts are monotonically increasing and record snapshot of those counters.
dhcpmon will report discrepancies when detected between current counters and
snapshot counters.

This patch replaces libpcap packet interworking packet capture with raw sockets
and libevent. Also, the program now executes as a single thread.

pull-request: sonic-net#3886
signed-off-by: Tamer Ahmed <tamer.ahmed@microsoft.com>
DHCP relay MONitor (dhcpmon) keeps track of DORA messages. DORA is acronym for
Discover/Offer/Request/ACK DHCP messages which happen in succession for a
successful DHCP transaction. If DHCP Relay is detected to be not forwarding DORA
message, dhcpmon will log such event to syslog. Under the hood dhcpmon keeps
counts of clients DR messages, forwarded DR messages, DHCP server OA messages,
and forwarded OA messages. dhcpmon will check every 12 sec (configurable) if
counts are monotonically increasing and record snapshot of those counters.
dhcpmon will report discrepancies when detected between current counters and
snapshot counters.

In this patch:
1. Address outstanding PR comments
  - Remove explicit package installation int the docker base image
  - Parameterize the compiler usage
  - Remove empty line
2. Update dhcpmon package dependencies
3. Remove MSG_TRUNC flag from raw socket recv as we dont report any packet
   truncation

pull-request: sonic-net#3886
signed-off-by: Tamer Ahmed <tamer.ahmed@microsoft.com>
address code comments, also updated some comment to refer to libevent instead
of libpcap.
@tahmed-dev tahmed-dev closed this Jan 8, 2020
@tahmed-dev tahmed-dev reopened this Jan 8, 2020
@tahmed-dev tahmed-dev merged commit 2658ab8 into sonic-net:master Jan 8, 2020
tahmed-dev added a commit to tahmed-dev/sonic-buildimage that referenced this pull request Jan 14, 2020
DHCP relay MONitor (dhcpmon) keeps track of DORA messages. If DHCP Relay
is detected to be not forwarding DORA message, dhcpmon will log such event
to syslog. Under the hood dhcpmon keeps counts of clients DR messages,
forwarded DR messages, DHCP server OA messages, and forwarded OA messages.
dhcpmon will check every 12 sec (configurable) if counts are monotonically
increasing and record snapshot of those counters. dhcpmon will report
discrepancies when detected between current counters and snapshot counters.

pull-request: sonic-net#3886
signed-off-by: Tamer Ahmed <tamer.ahmed@microsoft.com>
tahmed-dev added a commit that referenced this pull request Jan 14, 2020
* [dhcp-relay]: Add DHCP Relay Monitor (#3886)

DHCP relay MONitor (dhcpmon) keeps track of DORA messages. If DHCP Relay
is detected to be not forwarding DORA message, dhcpmon will log such event
to syslog. Under the hood dhcpmon keeps counts of clients DR messages,
forwarded DR messages, DHCP server OA messages, and forwarded OA messages.
dhcpmon will check every 12 sec (configurable) if counts are monotonically
increasing and record snapshot of those counters. dhcpmon will report
discrepancies when detected between current counters and snapshot counters.

pull-request: #3886
signed-off-by: Tamer Ahmed <tamer.ahmed@microsoft.com>

* Eliminate dependency on libexplain

* Remove dependency on libexplain
abdosi pushed a commit that referenced this pull request Jan 21, 2020
DHCP relay MONitor (dhcpmon) keeps track of DORA messages. If DHCP Relay
is detected to be not forwarding DORA message, dhcpmon will log such event
to syslog. Under the hood dhcpmon keeps counts of clients DR messages,
forwarded DR messages, DHCP server OA messages, and forwarded OA messages.
dhcpmon will check every 12 sec (configurable) if counts are monotonically
increasing and record snapshot of those counters. dhcpmon will report
discrepancies when detected between current counters and snapshot counters.

pull-request: #3886
signed-off-by: Tamer Ahmed <tamer.ahmed@microsoft.com>
pphuchar pushed a commit to SONIC-DEV/sonic-buildimage that referenced this pull request Mar 9, 2020
DHCP relay MONitor (dhcpmon) keeps track of DORA messages. If DHCP Relay
is detected to be not forwarding DORA message, dhcpmon will log such event
to syslog. Under the hood dhcpmon keeps counts of clients DR messages,
forwarded DR messages, DHCP server OA messages, and forwarded OA messages.
dhcpmon will check every 12 sec (configurable) if counts are monotonically
increasing and record snapshot of those counters. dhcpmon will report
discrepancies when detected between current counters and snapshot counters.

pull-request: sonic-net#3886
signed-off-by: Tamer Ahmed <tamer.ahmed@microsoft.com>
tiantianlv pushed a commit to SONIC-DEV/sonic-buildimage that referenced this pull request Apr 24, 2020
DHCP relay MONitor (dhcpmon) keeps track of DORA messages. If DHCP Relay
is detected to be not forwarding DORA message, dhcpmon will log such event
to syslog. Under the hood dhcpmon keeps counts of clients DR messages,
forwarded DR messages, DHCP server OA messages, and forwarded OA messages.
dhcpmon will check every 12 sec (configurable) if counts are monotonically
increasing and record snapshot of those counters. dhcpmon will report
discrepancies when detected between current counters and snapshot counters.

pull-request: sonic-net#3886
signed-off-by: Tamer Ahmed <tamer.ahmed@microsoft.com>
kellyyeh pushed a commit to sonic-net/sonic-dhcpmon that referenced this pull request Oct 11, 2022
DHCP relay MONitor (dhcpmon) keeps track of DORA messages. If DHCP Relay
is detected to be not forwarding DORA message, dhcpmon will log such event
to syslog. Under the hood dhcpmon keeps counts of clients DR messages,
forwarded DR messages, DHCP server OA messages, and forwarded OA messages.
dhcpmon will check every 12 sec (configurable) if counts are monotonically
increasing and record snapshot of those counters. dhcpmon will report
discrepancies when detected between current counters and snapshot counters.

pull-request: sonic-net/sonic-buildimage#3886
signed-off-by: Tamer Ahmed <tamer.ahmed@microsoft.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.

6 participants