Comments (9)
The question didn't specifically mention control plane software.
An example with some control plane code (in the form of unit tests) can be found here:
- https://github.com/p4lang/behavioral-model/blob/master/targets/simple_switch_grpc/tests/testdata/digest.p4
- https://github.com/p4lang/behavioral-model/blob/master/targets/simple_switch_grpc/tests/test_digest.cpp
And I believe the P4Runtime spec is pretty comprehensive regarding digest generation.
from behavioral-model.
Hi Christian,
AFAIK, learning has been fully implemented. Note that all generate_digest()
does is generate a learning notification that then needs to be handled by the control plane. It does not update any table by itself. That is what the learn client (https://github.com/p4lang/behavioral-model/tree/master/targets/l2_switch/learn_client) is for. This code is an example that is meant to be used in conjunction with the l2_switch binary and l2_switch.p4. It will receive learning notifications and populate tables appropriately. If you start l2_switch, then learn_client
you should see table entries being added as L2 traffic goes through.
from behavioral-model.
Hi Antonin,
I followed your instructions. I started l2_switch with the additional parameter
--notifications-addr ipc:///tmp/bmv2-0-notifications.ipc
to enable forwarding of notifications to the address that the learn_client
is listening on. Now it's working.
Thank you!
from behavioral-model.
There might be a bug in the learning engine: If I pass the first time a network packet to switch port 1, the new SRC MAC of the packet is notified and the learn_client
outputs:
I received 1 samples
Calling callback function
CB with 1 samples
ingress port is 1
So far, so good, but when I send a following packet with a different SRC MAC to switch port 2, the client outputs:
I received 1 samples
Calling callback function
CB with 1 samples
ingress port is 257
Subsequently port 101 (instead of port 2) is associated with the SRC MAC address in table 'dmac':
Action entry: forward - 101
Where the magic numbers 257 and 101 might come from?
from behavioral-model.
Well 0x101 is 257 so that's really one magic number :)
I'm not sure what could be going on. It may be useful if you could provide the command line with which you run the switch. I would also recommend running the switch with logging enable (--log-console
). You can then see if that strange number shows up anywhere or if the packet is shown as coming in on port 2.
from behavioral-model.
I launched the switch by command:
sudo ./l2_switch l2_switch.json -i 0@veth0 -i 1@veth2 -i 2@veth4 -i 3@veth6 -i 4@veth8 --nanolog ipc:///tmp/bm-0-log.ipc --log-console -L debug --notifications-addr ipc:///tmp/bmv2-0-notifications.ipc --pcap
Thereafter I sent the first network packet (SRC MAC aabbccddeef1, DST MAC aabbccddeef2) on port 1 and subsequently the second packet (SRC MAC aabbccddeef2, DST MAC aabbccddeef1) on port 2. For the second packet the switch generated the following output:
[16:31:12.170] [bmv2] [D] [thread 31314] [1.0] [cxt 0] Processing packet received on port 2
2
[16:31:12.170] [bmv2] [D] [thread 31314] [1.0] [cxt 0] Parser 'parser': start
Some output removed for brevity...
[16:31:12.171] [bmv2] [D] [thread 31314] [1.0] [cxt 0] Looking up key:
- ethernet.dstAddr : aabbccddeef1
[16:31:12.171] [bmv2] [D] [thread 31314] [1.0] [cxt 0] Table 'dmac': hit with handle 0
[16:31:12.171] [bmv2] [D] [thread 31314] [1.0] [cxt 0] Dumping entry 0
Match key:
- ethernet.dstAddr : EXACT aabbccddeef1
Action entry: forward - 1,[16:31:12.171] [bmv2] [D] [thread 31314] [1.0] [cxt 0] Action entry is forward - 1,
[16:31:12.171] [bmv2] [D] [thread 31314] [1.0] [cxt 0] Pipeline 'ingress': end
[16:31:12.171] [bmv2] [D] [thread 31314] [1.0] [cxt 0] Egress port is 1
[16:31:12.171] [bmv2] [D] [thread 31314] [1.0] [cxt 0] Learn id is 1
[16:31:12.171] [bmv2] [D] [thread 31314] [1.0] [cxt 0] Mgid is 0
[16:31:12.171] [bmv2] [D] [thread 31314] [1.0] [cxt 0] Pipeline 'egress': start
[16:31:12.171] [bmv2] [D] [thread 31314] [1.0] [cxt 0] Pipeline 'egress': end
[16:31:12.172] [bmv2] [D] [thread 31315] [1.0] [cxt 0] Transmitting packet of size 73 out of port 1
OK - port 1 is the right output port!
[16:31:13.173] [bmv2] [D] [thread 31335] Entry 1 added to table 'smac'
[16:31:13.173] [bmv2] [D] [thread 31335] Dumping entry 1
Match key:
- ethernet.srcAddr : EXACT aabbccddeef2
Action entry: _nop -[16:31:13.174] [bmv2] [D] [thread 31335] Entry 1 added to table 'dmac'
[16:31:13.174] [bmv2] [D] [thread 31335] Dumping entry 1
Match key:
- ethernet.dstAddr : EXACT aabbccddeef2
Everything is fine up to here, but the last line of switch logging output contains the magic number that associates MAC aabbccddeef2 with port 257:
Action entry: forward - 101,
Content of table 'dmac':
RuntimeCmd: table_dump dmac
dmac:
0: aabbccddeef1 => forward - 0,
1: aabbccddeef2 => forward - 101,
default: broadcast -
from behavioral-model.
This was addressed in ff0cdf4
There was a "legacy hack" in l2_switch.p4 that was overwriting the ingress port value to 257. Thanks for reporting this.
from behavioral-model.
If the l2_switch example is not enough for you, I believe @jafingerhut has an example here: https://github.com/jafingerhut/p4-guide/tree/master/control-plane-types
BTW, do not use the P4 public forums to ask about Tofino. Refer to the available customer documentation or reach out to Barefoot customer engineering.
from behavioral-model.
FYI, I do not recall any code example in my p4-guide Github repository have working examples of digests sent to control software, at least not yet. The program you link to does have P4_16 source code that calls the v1model digest extern function, but I have never tried to get those messages to control software before.
from behavioral-model.
Related Issues (20)
- import thrift
- TCP packets seem not to be processed correctly by bmv2 HOT 2
- Problem using multicast in runtime HOT 2
- Empty action-parameter vector is always accessed in ActionFnEntry::execute HOT 7
- How to build behavioral-model on the MacOS(Apple M1 Pro(13.5)) HOT 2
- How to track fileds of metadata with p4dbg? HOT 2
- Approximate conversion of bmv2 p4 performance to hardware performance HOT 3
- Applying the same table twice HOT 2
- Required to set forwarding pipeline before using the dataplane for streaming packets HOT 10
- Update project to require C++17 HOT 9
- Race conditions when passing in a BMv2 JSON config HOT 12
- To Add PNA support into BMv2. HOT 5
- How to build simple_switch / simple_switch_grpc on Ubuntu 24.04 ? HOT 4
- Why bmi_port.c is a C code? HOT 2
- Race conditions when processing packet in the egress pipeline. HOT 6
- Heap Buffer Overflow when installing many table entries HOT 1
- CMake support HOT 4
- Queue metadata with multiqueue HOT 2
- Where is the original p4 source code for recirc.json HOT 8
- Consider implementing something like Tuple Space Search for ternary table lookups
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from behavioral-model.