diff --git a/platform/marvell-armhf/sonic-platform-nokia/debian/sonic-platform-nokia-7215.install b/platform/marvell-armhf/sonic-platform-nokia/debian/sonic-platform-nokia-7215.install index 0b867d259f..dc4df5540d 100644 --- a/platform/marvell-armhf/sonic-platform-nokia/debian/sonic-platform-nokia-7215.install +++ b/platform/marvell-armhf/sonic-platform-nokia/debian/sonic-platform-nokia-7215.install @@ -3,3 +3,5 @@ nokia-7215_plt_setup.sh usr/sbin 7215/service/nokia-7215init.service etc/systemd/system 7215/sonic_platform-1.0-py2-none-any.whl usr/share/sonic/device/armhf-nokia_ixs7215_52x-r0 7215/sonic_platform-1.0-py3-none-any.whl usr/share/sonic/device/armhf-nokia_ixs7215_52x-r0 +entropy.py etc/ +inband_mgmt.sh etc/ diff --git a/platform/marvell-armhf/sonic-platform-nokia/entropy.py b/platform/marvell-armhf/sonic-platform-nokia/entropy.py new file mode 100644 index 0000000000..338e2ad9bc --- /dev/null +++ b/platform/marvell-armhf/sonic-platform-nokia/entropy.py @@ -0,0 +1,19 @@ +#!/usr/bin/python +import fcntl, struct +import time +from os import path + +RNDADDENTROPY=0x40085203 + +def avail(): + with open("/proc/sys/kernel/random/entropy_avail", mode='r') as avail: + return int(avail.read()) + +if path.exists("/proc/sys/kernel/random/entropy_avail"): + while 1: + while avail() < 2048: + with open('/dev/urandom', 'rb') as urnd, open("/dev/random", mode='wb') as rnd: + d = urnd.read(512) + t = struct.pack('ii', 4 * len(d), len(d)) + d + fcntl.ioctl(rnd, RNDADDENTROPY, t) + time.sleep(30) diff --git a/platform/marvell-armhf/sonic-platform-nokia/inband_mgmt.sh b/platform/marvell-armhf/sonic-platform-nokia/inband_mgmt.sh new file mode 100644 index 0000000000..25455d16ec --- /dev/null +++ b/platform/marvell-armhf/sonic-platform-nokia/inband_mgmt.sh @@ -0,0 +1,28 @@ +#!/bin/sh + +#inband_mgmt + +inband_mgmt(){ + # In this platform, one of the network ports is used as mgmt interface. + # This script periodically monitors inband management port eth0 and + # assigns IP address to eth0 if needed. + if [ ! -f /host/machine.conf ]; then + exit 0 + fi + #wait for n/w port init to complete + sleep 60 + while :; do + ip -br link show eth0 2> /dev/null + if [ $? -eq 0 ]; then + ip address show eth0 | grep -qw "inet" 2>/dev/null + if [ $? -ne 0 ]; then + ifconfig eth0 down + systemctl restart networking + fi + sleep 120 + else + sleep 3 + fi + done +} +(inband_mgmt > /dev/null)& diff --git a/platform/marvell-armhf/sonic-platform-nokia/nokia-7215_plt_setup.sh b/platform/marvell-armhf/sonic-platform-nokia/nokia-7215_plt_setup.sh index e4fc716cf5..8301999d0d 100755 --- a/platform/marvell-armhf/sonic-platform-nokia/nokia-7215_plt_setup.sh +++ b/platform/marvell-armhf/sonic-platform-nokia/nokia-7215_plt_setup.sh @@ -30,6 +30,9 @@ main() { fw_uboot_env_cfg echo "Nokia-IXS7215: /dev/mtd0 FW_ENV_DEFAULT" + + python /etc/entropy.py & + /bin/sh /etc/inband_mgmt.sh } main $@