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

[docker-teamd]: Explicitly set LAG hwaddr #664

Merged
merged 5 commits into from
Jun 6, 2017
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion dockers/docker-teamd/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,18 @@ TEAMD_CONF_PATH=/etc/teamd
rm -rf $TEAMD_CONF_PATH
mkdir -p $TEAMD_CONF_PATH

SONIC_ASIC_TYPE=$(sonic-cfggen -y /etc/sonic/sonic_version.yml -v asic_type)
MAC_ADDRESS=$(ip link show eth0 | grep ether | awk '{print $2}')

# Align last byte
if [ "$SONIC_ASIC_TYPE" == "mellanox" -o "$SONIC_ASIC_TYPE" == "centec" ]; then
last_byte=$(python -c "print '$MAC_ADDRESS'[-2:]")
aligned_last_byte=$(python -c "print format(int(int('$last_byte', 16) & 0b11000000), '02x')") # put mask and take away the 0x prefix
MAC_ADDRESS=$(python -c "print '$MAC_ADDRESS'[:-2] + '$aligned_last_byte'") # put aligned byte into the end of MAC
fi

for pc in `sonic-cfggen -m /etc/sonic/minigraph.xml -v "minigraph_portchannels.keys() | join(' ')"`; do
sonic-cfggen -m /etc/sonic/minigraph.xml -a '{"pc":"'$pc'"}' -t /usr/share/sonic/templates/teamd.j2 > $TEAMD_CONF_PATH/$pc.conf
sonic-cfggen -m /etc/sonic/minigraph.xml -a '{"pc":"'$pc'","hwaddr":"'$MAC_ADDRESS'"}' -t /usr/share/sonic/templates/teamd.j2 > $TEAMD_CONF_PATH/$pc.conf
done

mkdir -p /var/sonic
Expand Down
1 change: 1 addition & 0 deletions dockers/docker-teamd/teamd.j2
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"device": "{{ pc }}",
"hwaddr": "{{ hwaddr }}",
"runner": {
"name": "lacp",
"active": true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"device": "PortChannel01",
"hwaddr": "11:22:33:44:55:66",
"runner": {
"name": "lacp",
"active": true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"device": "PortChannel02",
"hwaddr": "11:22:33:44:55:66",
"runner": {
"name": "lacp",
"active": true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"device": "PortChannel03",
"hwaddr": "11:22:33:44:55:66",
"runner": {
"name": "lacp",
"active": true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"device": "PortChannel04",
"hwaddr": "11:22:33:44:55:66",
Copy link
Collaborator

Choose a reason for hiding this comment

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

11 is multicast address, not a valid src mac address.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

"runner": {
"name": "lacp",
"active": true,
Expand Down
2 changes: 1 addition & 1 deletion src/sonic-config-engine/tests/test_j2files.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def test_teamd(self):
def test_render_teamd(self, pc):
teamd_file = os.path.join(self.test_dir, '..', '..', '..', 'dockers', 'docker-teamd', 'teamd.j2')
sample_output_file = os.path.join(self.test_dir, 'sample_output',pc + '.conf')
argument = '-m ' + self.t0_minigraph + ' -p ' + self.t0_port_config + ' -a \'{\"pc\":\"' + pc + '\"}\' -t ' + teamd_file + ' > ' + self.output_file
argument = '-m ' + self.t0_minigraph + ' -p ' + self.t0_port_config + ' -a \'{\"pc\":\"' + pc + '\",\"hwaddr\":\"11:22:33:44:55:66\"}\' -t ' + teamd_file + ' > ' + self.output_file
self.run_script(argument)
assert filecmp.cmp(sample_output_file, self.output_file)

Expand Down