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

Add drop reason example #7

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Add drop reason example #7

wants to merge 1 commit into from

Conversation

vbnogueira
Copy link
Contributor

@vbnogueira vbnogueira commented Oct 8, 2024

Add drop reason example that drops a packet, and sends a digest message
containing the ingress port (port where the packet arrived), the src
mac address and the drop reason (PARSER_REJECTED or TABLE_MISS)
If the packet is not dropped, it will be redirected

@vbnogueira vbnogueira requested a review from jhsmt October 8, 2024 00:37
@vbnogueira vbnogueira self-assigned this Oct 8, 2024
@vbnogueira vbnogueira marked this pull request as draft October 8, 2024 00:50
@vbnogueira vbnogueira force-pushed the add_digest_example branch 2 times, most recently from ae0e39b to 6ac97e2 Compare October 8, 2024 13:03
@vbnogueira vbnogueira marked this pull request as ready for review October 8, 2024 13:03
@vbnogueira vbnogueira marked this pull request as draft October 18, 2024 17:38
digest/README.md Outdated
@@ -0,0 +1,254 @@
# digest

Copy link
Contributor

Choose a reason for hiding this comment

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

I am tempted to call this: drop_reason instead of digest. Then the opening statement here is:
This program demonstrates how to capture events from the datapath and logging them as events to the control plane. In this case we capture the reason why packets are dropped, what port they arrived on and what src mac address was observed on the packet. Packets could be dropped for two reasons:

  1. the parser was unable to parse the packet
  2. unable to find a matching entry on lookup of table nh_table.

digest/README.md Outdated
rejected. After the parser recognizes an ipv4 packet, the src ip address is used as a lookup
key for table *nh_table*. On a table hit, the programmed action *send_nh(port, srcMac, dstMac)* instance is executed.
The action first sets the src and destination mac address, then redirects the packet to a specified port, sets the ingress_port, sets `send_digest` to true and redirects the packet. On a table miss the packet is simply dropped.
`my_ingress_metadata_t` will hold the port on where the packet arrived and `send_digest`. `send_digest` signals to the deparser to send a digest message to user space. This digest message will hold the source mac address and the port where the packet arrived:
Copy link
Contributor

Choose a reason for hiding this comment

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

s/dropped/dropped and event sent to the control plane with reason set to blah

digest/README.md Outdated

run TC monitor for digest events:
`$TC mon p4 digest`

Copy link
Contributor

Choose a reason for hiding this comment

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

We need to see the events here..

digest/README.md Outdated
Compile the parser and control blocks programs if you have not already

`make`

Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldnt you compile first before you modprobe?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It doesn't matter
I can modprobe before or after

digest/README.md Outdated
`ping -I p4port0 10.0.1.2 -c 1`

Let's check some stats, below shows 3 packets dropped by the parser on <u>terminal 3</u>:

Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldnt you point the user to terminal 2 at this point? And what they should expect to see?
And what was the packet dropped by the parser.
You are literally cutting and pasting other examples i had without thinking through what useful information is needed for the user..

Copy link
Contributor Author

@vbnogueira vbnogueira Oct 18, 2024

Choose a reason for hiding this comment

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

That's why I transformed it into a draft, because I needed to fix it given the new semantic
It's just copied and pasted at this point, I'm fixing and testing it before making the PR ready for review

digest/README.md Outdated
# digest

The *digest* program first parses ethernet <u>ipv4</u> packets. Any other packets are
rejected. After the parser recognizes an ipv4 packet, the src ip address is used as a lookup
Copy link
Contributor

Choose a reason for hiding this comment

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

s/rejected/rejected and event blah blah sent to the control plane.

parser_rejected = 1,
table_miss = 2
};

Copy link
Contributor

Choose a reason for hiding this comment

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

Should the DROP_REASON be capitalized?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think that would work also

"bitwidth" : 8
}
]
}
Copy link
Contributor

Choose a reason for hiding this comment

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

We need the drop reason not as a number but as a name for human consumption. Maybe i am missing something.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We discussed offline and what we'd like would be for the compiler to emit in the JSON the mapping from integer to corresponding enum string (parser_rejected or table_miss)

@vbnogueira vbnogueira force-pushed the add_digest_example branch 3 times, most recently from 42ec0a5 to e10a2f5 Compare October 18, 2024 21:43
Add drop reason example  that drops a packet, and sends a digest message
containing the ingress port (port where the packet arrived), the src
mac address and the drop reason (PARSER_REJECTED or TABLE_MISS)
If the packet is not dropped, it will be redirected
@vbnogueira vbnogueira changed the title Add digest example Add drop reason example Oct 18, 2024
@jhsmt jhsmt marked this pull request as ready for review October 18, 2024 21:48
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