-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use front panel names in the clab topology (#206)
- Loading branch information
1 parent
5f2450e
commit d1e34c9
Showing
6 changed files
with
295 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/bin/bash | ||
|
||
# Script is taken from https://netdevops.me/2021/transparently-redirecting-packetsframes-between-interfaces/ | ||
# Read it for better understanding | ||
|
||
TAP_IF=$1 | ||
# get interface index number up to 3 digits (everything after first three chars) | ||
# tap0 -> 0 | ||
# tap123 -> 123 | ||
INDEX=${TAP_IF:3:3} | ||
|
||
# tap$INDEX corresponds to eth$INDEX in the virtual machine | ||
# The virtual switch assigns lanes to the Linux interface ethX. The assignment is specified in the lanemap.ini file in the following format: ethX:<lanes>. | ||
LANES=$(grep ^eth$INDEX: /lanemap.ini | cut -d':' -f2) | ||
# Identify the front panel using the lanes. | ||
FRONT_PANEL=$(grep -E "^Ethernet[0-9]+\s+$LANES\s+Eth" /port_config.ini | cut -d' ' -f1) | ||
|
||
ip link set $TAP_IF up | ||
ip link set $TAP_IF mtu 65000 | ||
|
||
# create tc Ethernet<->tap redirect rules | ||
tc qdisc add dev $FRONT_PANEL ingress | ||
tc filter add dev $FRONT_PANEL parent ffff: protocol all u32 match u8 0 0 action mirred egress redirect dev $TAP_IF | ||
|
||
tc qdisc add dev $TAP_IF ingress | ||
tc filter add dev $TAP_IF parent ffff: protocol all u32 match u8 0 0 action mirred egress redirect dev $FRONT_PANEL |
Oops, something went wrong.