Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/202305' into frr_mem_com
Browse files Browse the repository at this point in the history
  • Loading branch information
dgsudharsan committed Mar 14, 2024
2 parents fe25d6b + b1daba8 commit e60d827
Show file tree
Hide file tree
Showing 17 changed files with 81 additions and 162 deletions.
9 changes: 3 additions & 6 deletions Makefile.work
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ rules/config.user:

include rules/config
-include rules/config.user
include rules/sonic-fips.mk

ifneq ($(DEFAULT_CONTAINER_REGISTRY),)
override DEFAULT_CONTAINER_REGISTRY := $(DEFAULT_CONTAINER_REGISTRY)/
Expand Down Expand Up @@ -177,12 +178,6 @@ endif
SLAVE_IMAGE = $(SLAVE_BASE_IMAGE)-$(USER_LC)
DOCKER_ROOT = $(PWD)/fsroot.docker.$(BLDENV)

# Support FIPS feature, armhf not supported yet
ifeq ($(PLATFORM_ARCH),armhf)
ENABLE_FIPS_FEATURE := n
ENABLE_FIPS := n
endif

ifeq ($(ENABLE_FIPS_FEATURE), n)
ifeq ($(ENABLE_FIPS), y)
$(error Cannot set fips config ENABLE_FIPS=y when ENABLE_FIPS_FEATURE=n)
Expand Down Expand Up @@ -216,6 +211,8 @@ $(shell CONFIGURED_ARCH=$(CONFIGURED_ARCH) \
DOCKER_EXTRA_OPTS=$(DOCKER_EXTRA_OPTS) \
DEFAULT_CONTAINER_REGISTRY=$(DEFAULT_CONTAINER_REGISTRY) \
GZ_COMPRESS_PROGRAM=$(GZ_COMPRESS_PROGRAM) \
FIPS_VERSION=$(FIPS_VERSION) \
FIPS_GOLANG_VERSION=$(FIPS_GOLANG_VERSION) \
j2 $(SLAVE_DIR)/Dockerfile.j2 > $(SLAVE_DIR)/Dockerfile)

$(shell CONFIGURED_ARCH=$(CONFIGURED_ARCH) \
Expand Down
14 changes: 7 additions & 7 deletions device/celestica/x86_64-cel_e1031-r0/sonic_platform/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ class Common:

SET_METHOD_IPMI = 'ipmitool'
NULL_VAL = 'N/A'
HOST_CHK_CMD = ["docker"]
REF_KEY = '$ref:'

def __init__(self, conf=None):
Expand Down Expand Up @@ -184,12 +183,13 @@ def write_txt_file(self, file_path, value):
return False
return True

def is_host(self):
try:
subprocess.call(self.HOST_CHK_CMD, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
except FileNotFoundError:
return False
return True
def is_host():
"""
Test whether current process is running on the host or an docker
return True for host and False for docker
"""
docker_env_file = '/.dockerenv'
return os.path.exists(docker_env_file) is False

def load_json_file(self, path):
"""
Expand Down
2 changes: 0 additions & 2 deletions dockers/docker-dhcp-relay/Dockerfile.j2
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ ENV IMAGE_VERSION=$image_version
# Update apt's cache of available packages
RUN apt-get update

RUN apt-get install -y libjsoncpp-dev

{% if docker_dhcp_relay_debs.strip() -%}
# Copy built Debian packages
{{ copy_files("debs/", docker_dhcp_relay_debs.split(' '), "/debs/") }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,24 @@
except KeyError:
pass

expected_counts_v6 = """\
Message Type Vlan1000(RX)
-------------- ---------------
Message Type Vlan1000(TX)
-------------- ---------------
"""

expected_counts_v4 = """\
Message Type Vlan1000(RX)
-------------- ---------------
Message Type Vlan1000(TX)
-------------- ---------------
expected_counts = """\
Message Type Vlan1000
------------------- -----------
Unknown
Solicit
Advertise
Request
Confirm
Renew
Rebind
Reply
Release
Decline
Reconfigure
Information-Request
Relay-Forward
Relay-Reply
Malformed
"""

Expand All @@ -40,14 +43,5 @@ class TestDhcp6RelayCounters(object):
def test_show_counts(self):
runner = CliRunner()
result = runner.invoke(show.dhcp6relay_counters.commands["counts"], ["-i Vlan1000"])
print(result.output)
assert result.output == expected_counts_v6

class TestDhcpRelayCounters(object):

def test_show_counts(self):
runner = CliRunner()
result = runner.invoke(show.dhcp4relay_counters.commands["counts"], ["-i Vlan1000"])
print(result.output)
assert result.output == expected_counts_v4
assert result.output == expected_counts

122 changes: 19 additions & 103 deletions dockers/docker-dhcp-relay/cli/show/plugins/show_dhcp_relay.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import click
import ast
from natsort import natsorted
from tabulate import tabulate
import show.vlan as show_vlan
Expand All @@ -8,20 +7,13 @@
from swsscommon.swsscommon import ConfigDBConnector
from swsscommon.swsscommon import SonicV2Connector


# STATE_DB Table
DHCPv4_COUNTER_TABLE = 'DHCP_COUNTER_TABLE'
DHCPv6_COUNTER_TABLE = 'DHCPv6_COUNTER_TABLE'

# DHCPv4 Counter Messages
dhcpv4_messages = [
"Unknown", "Discover", "Offer", "Request", "Decline", "Ack", "Nack", "Release", "Inform"
]

# DHCPv6 Counter Messages
dhcpv6_messages = [
"Unknown", "Solicit", "Advertise", "Request", "Confirm", "Renew", "Rebind", "Reply", "Release",
"Decline", "Reconfigure", "Information-Request", "Relay-Forward", "Relay-Reply", "Malformed"
]
messages = ["Unknown", "Solicit", "Advertise", "Request", "Confirm", "Renew", "Rebind", "Reply", "Release", "Decline",
"Reconfigure", "Information-Request", "Relay-Forward", "Relay-Reply", "Malformed"]

# DHCP_RELAY Config Table
DHCP_RELAY = 'DHCP_RELAY'
Expand All @@ -45,75 +37,6 @@ def get_dhcp_helper_address(ctx, vlan):

show_vlan.VlanBrief.register_column('DHCP Helper Address', get_dhcp_helper_address)

class DHCPv4_Counter(object):
def __init__(self):
self.db = SonicV2Connector(use_unix_socket_path=False)
self.db.connect(self.db.STATE_DB)
self.table_name = DHCPv4_COUNTER_TABLE + self.db.get_db_separator(self.db.STATE_DB)

def get_interface(self):
""" Get all names of all interfaces in DHCPv4_COUNTER_TABLE """
interfaces = []
for key in self.db.keys(self.db.STATE_DB):
if DHCPv4_COUNTER_TABLE in key:
interfaces.append(key[21:])
return interfaces

def get_dhcp4relay_msg_count(self, interface, dir):
""" Get count of a dhcprelay message """
value = self.db.get(self.db.STATE_DB, self.table_name + str(interface), str(dir))
cnts = ast.literal_eval(str(value))
data = []
if cnts is not None:
for k, v in cnts.items():
data.append([k, v])
return data

def clear_table(self, interface):
""" Reset all message counts to 0 """
v4_cnts = {}
for msg in dhcpv4_messages:
v4_cnts[msg] = '0'
self.db.set(self.db.STATE_DB, self.table_name + str(interface), str("RX"), str(v4_cnts))
self.db.set(self.db.STATE_DB, self.table_name + str(interface), str("TX"), str(v4_cnts))

def print_dhcpv4_count(counter, intf):
"""Print count of each message"""
rx_data = counter.get_dhcp4relay_msg_count(intf, "RX")
print(tabulate(rx_data, headers=["Message Type", intf+"(RX)"], tablefmt='simple', stralign='right') + "\n")
tx_data = counter.get_dhcp4relay_msg_count(intf, "TX")
print(tabulate(tx_data, headers=["Message Type", intf+"(TX)"], tablefmt='simple', stralign='right') + "\n")

#
# 'dhcp4relay_counters' group ###
#


@click.group(cls=clicommon.AliasedGroup, name="dhcp4relay_counters")
def dhcp4relay_counters():
"""Show DHCPv4 counter"""
pass


def ipv4_counters(interface):
counter = DHCPv4_Counter()
counter_intf = counter.get_interface()

if interface:
print_dhcpv4_count(counter, interface)
else:
for intf in counter_intf:
print_dhcpv4_count(counter, intf)


# 'counts' subcommand ("show dhcp4relay_counters counts")
@dhcp4relay_counters.command('counts')
@click.option('-i', '--interface', required=False)
@click.option('--verbose', is_flag=True, help="Enable verbose output")
def counts(interface, verbose):
"""Show dhcp4relay message counts"""
ipv4_counters(interface)


class DHCPv6_Counter(object):
def __init__(self):
Expand All @@ -123,37 +46,30 @@ def __init__(self):

def get_interface(self):
""" Get all names of all interfaces in DHCPv6_COUNTER_TABLE """
interfaces = []
vlans = []
for key in self.db.keys(self.db.STATE_DB):
if DHCPv6_COUNTER_TABLE in key:
interfaces.append(key[21:])
return interfaces
vlans.append(key[21:])
return vlans

def get_dhcp6relay_msg_count(self, interface, dir):
def get_dhcp6relay_msg_count(self, interface, msg):
""" Get count of a dhcp6relay message """
value = self.db.get(self.db.STATE_DB, self.table_name + str(interface), str(dir))
cnts = ast.literal_eval(str(value))
data = []
if cnts is not None:
for k, v in cnts.items():
data.append([k, v])
count = self.db.get(self.db.STATE_DB, self.table_name + str(interface), str(msg))
data = [str(msg), count]
return data

def clear_table(self, interface):
""" Reset all message counts to 0 """
v6_cnts = {}
for msg in dhcpv6_messages:
v6_cnts[msg] = '0'
self.db.set(self.db.STATE_DB, self.table_name + str(interface), str("RX"), str(v6_cnts))
self.db.set(self.db.STATE_DB, self.table_name + str(interface), str("TX"), str(v6_cnts))
for msg in messages:
self.db.set(self.db.STATE_DB, self.table_name + str(interface), str(msg), '0')


def print_dhcpv6_count(counter, intf):
def print_count(counter, intf):
"""Print count of each message"""
rx_data = counter.get_dhcp6relay_msg_count(intf, "RX")
print(tabulate(rx_data, headers=["Message Type", intf+"(RX)"], tablefmt='simple', stralign='right') + "\n")
tx_data = counter.get_dhcp6relay_msg_count(intf, "TX")
print(tabulate(tx_data, headers=["Message Type", intf+"(TX)"], tablefmt='simple', stralign='right') + "\n")
data = []
for i in messages:
data.append(counter.get_dhcp6relay_msg_count(intf, i))
print(tabulate(data, headers=["Message Type", intf], tablefmt='simple', stralign='right') + "\n")


#
Expand All @@ -172,10 +88,10 @@ def ipv6_counters(interface):
counter_intf = counter.get_interface()

if interface:
print_dhcpv6_count(counter, interface)
print_count(counter, interface)
else:
for intf in counter_intf:
print_dhcpv6_count(counter, intf)
print_count(counter, intf)


# 'counts' subcommand ("show dhcp6relay_counters counts")
Expand All @@ -184,6 +100,7 @@ def ipv6_counters(interface):
@click.option('--verbose', is_flag=True, help="Enable verbose output")
def counts(interface, verbose):
"""Show dhcp6relay message counts"""

ipv6_counters(interface)


Expand Down Expand Up @@ -282,7 +199,6 @@ def dhcp_relay_ip6counters(interface):


def register(cli):
cli.add_command(dhcp4relay_counters)
cli.add_command(dhcp6relay_counters)
cli.add_command(dhcp_relay_helper)
cli.add_command(dhcp_relay)
1 change: 1 addition & 0 deletions files/build_templates/sonic_debian_extension.j2
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ sudo https_proxy=$https_proxy LANG=C chroot $FILESYSTEM_ROOT pip3 install system
# Install SONiC host services package
SONIC_HOST_SERVICES_PY3_WHEEL_NAME=$(basename {{sonic_host_services_py3_wheel_path}})
sudo cp {{sonic_host_services_py3_wheel_path}} $FILESYSTEM_ROOT/$SONIC_HOST_SERVICES_PY3_WHEEL_NAME
sudo https_proxy=$https_proxy LANG=C chroot $FILESYSTEM_ROOT pip3 install pygobject
sudo https_proxy=$https_proxy LANG=C chroot $FILESYSTEM_ROOT pip3 install $SONIC_HOST_SERVICES_PY3_WHEEL_NAME
sudo rm -rf $FILESYSTEM_ROOT/$SONIC_HOST_SERVICES_PY3_WHEEL_NAME

Expand Down
3 changes: 2 additions & 1 deletion files/image_config/kdump/kdump-tools
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ KDUMP_CMDLINE_APPEND="irqpoll nr_cpus=1 nousb systemd.unit=kdump-tools.service a

# Reboot crash kernel on panic
# Enable debug level logging of crash kernel for better visibility
# Set loglevel to reduce verbosity and print only warning conditions
# Disable advanced pcie features
# Disable high precision event timer as on some platforms it is interfering with the kdump operation
# Pass platform identifier string as part of crash kernel command line to be used by the reboot script during kdump
KDUMP_CMDLINE_APPEND="${KDUMP_CMDLINE_APPEND} panic=10 debug hpet=disable pcie_port=compat pci=nommconf sonic_platform=__PLATFORM__"
KDUMP_CMDLINE_APPEND="${KDUMP_CMDLINE_APPEND} panic=10 debug loglevel=4 hpet=disable pcie_port=compat pci=nommconf sonic_platform=__PLATFORM__"

# Use SONiC reboot wrapper script present in /usr/local/bin post kdump
PATH=/usr/local/bin:$PATH
4 changes: 4 additions & 0 deletions platform/vs/docker-sonic-vs.mk
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ else
$(DOCKER_SONIC_VS)_DEPENDS += $(GOBGP)
endif

ifeq ($(ENABLE_FIPS_FEATURE), y)
$(DOCKER_SONIC_VS)_DEPENDS += $(FIPS_KRB5_ALL)
endif

$(DOCKER_SONIC_VS)_FILES += $(CONFIGDB_LOAD_SCRIPT) \
$(ARP_UPDATE_SCRIPT) \
$(ARP_UPDATE_VARS_TEMPLATE) \
Expand Down
13 changes: 7 additions & 6 deletions platform/vs/docker-sonic-vs/Dockerfile.j2
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ RUN [ -f /etc/rsyslog.conf ] && sed -ri "s/%syslogtag%/$docker_container_name#%s
ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update && apt-get install -y gnupg
COPY ["sonic-dev.gpg.key", "/etc/apt/"]
RUN apt-key add /etc/apt/sonic-dev.gpg.key
RUN echo "deb http://packages.microsoft.com/repos/sonic-dev/ jessie main" >> /etc/apt/sources.list
RUN apt-get update

RUN apt-get install -y net-tools \
arping \
Expand Down Expand Up @@ -42,7 +38,6 @@ RUN apt-get install -y net-tools \
iptables \
jq \
libzmq5 \
libzmq3-dev \
uuid-dev \
# For installing Python m2crypto package
# (these can be uninstalled after installation)
Expand All @@ -68,7 +63,11 @@ RUN apt-get install -y net-tools \
libasan6 \
{%- endif %}
dbus \
redis-server
redis-server \
# For libkrb5-dev
comerr-dev \
libgssrpc4 \
libkdb5-10

# For sonic-config-engine Python 3 package
# Install pyangbind here, outside sonic-config-engine dependencies, as pyangbind causes enum34 to be installed.
Expand All @@ -92,6 +91,8 @@ COPY {%- for deb in docker_sonic_vs_debs.split(' ') %} debs/{{ deb }}{%- endfor
RUN dpkg_apt() { [ -f $1 ] && { dpkg -i $1 || apt-get -y install -f; } || return 1; }; {%- for deb in docker_sonic_vs_debs.split(' ') %} dpkg_apt /debs/{{ deb }};{%- endfor %}
{%- endif %}

RUN apt-get install -y libzmq3-dev

{% if docker_sonic_vs_pydebs.strip() -%}
# Copy locally-built Debian package dependencies
COPY {%- for deb in docker_sonic_vs_pydebs.split(' ') %} python-debs/{{ deb }}{%- endfor %} /debs/
Expand Down
Loading

0 comments on commit e60d827

Please sign in to comment.