Skip to content

Commit

Permalink
Fix the merge conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
pavel-shirshov committed Jun 12, 2018
2 parents 55f4432 + fd7392f commit 260730a
Show file tree
Hide file tree
Showing 16 changed files with 53 additions and 413 deletions.
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
mode=3
hwId=as7512
netdevMode=1
aclEntryMaxPrio=1024
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
mode=0
hwId=as7512
netdevMode=1
aclEntryMaxPrio=1024
2 changes: 2 additions & 0 deletions device/accton/x86_64-accton_as7512_32x-r0/AS7512/sai.profile
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
mode=1
hwId=as7512
netdevMode=1
aclEntryMaxPrio=1024
5 changes: 0 additions & 5 deletions files/build_templates/sonic_debian_extension.j2
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,6 @@ sudo cp $IMAGE_CONFIGS/hostname/hostname-config.service $FILESYSTEM_ROOT/etc/sy
sudo LANG=C chroot $FILESYSTEM_ROOT systemctl enable hostname-config.service
sudo cp $IMAGE_CONFIGS/hostname/hostname-config.sh $FILESYSTEM_ROOT/usr/bin/

# Copy serial-port-watchdog configuration scripts
sudo cp $IMAGE_CONFIGS/serial-port-watchdog/serial-port-watchdog.service $FILESYSTEM_ROOT/etc/systemd/system/
sudo LANG=C chroot $FILESYSTEM_ROOT systemctl enable serial-port-watchdog.service
sudo cp $IMAGE_CONFIGS/serial-port-watchdog/serial-port-watchdog.py $FILESYSTEM_ROOT/usr/bin/

# Copy updategraph script and service file
sudo cp $IMAGE_CONFIGS/updategraph/updategraph.service $FILESYSTEM_ROOT/etc/systemd/system/
sudo LANG=C chroot $FILESYSTEM_ROOT systemctl enable updategraph.service
Expand Down
31 changes: 30 additions & 1 deletion files/image_config/caclmgrd/caclmgrd
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#

try:
import ipaddr as ipaddress
import os
import subprocess
import sys
Expand Down Expand Up @@ -113,12 +114,22 @@ class ControlPlaneAclManager(object):
# Add iptables command to delete all non-default chains
iptables_cmds.append("iptables -X")

# Add same set of commands for ip6tables
iptables_cmds.append("ip6tables -P INPUT ACCEPT")
iptables_cmds.append("ip6tables -P FORWARD ACCEPT")
iptables_cmds.append("ip6tables -P OUTPUT ACCEPT")
iptables_cmds.append("ip6tables -F")
iptables_cmds.append("ip6tables -X")

# Get current ACL tables and rules from Config DB
self._tables_db_info = self.config_db.get_table(self.ACL_TABLE)
self._rules_db_info = self.config_db.get_table(self.ACL_RULE)

# Walk the ACL tables
for (table_name, table_data) in self._tables_db_info.iteritems():

table_ip_version = None

# Ignore non-control-plane ACL tables
if table_data["type"] != self.ACL_TABLE_TYPE_CTRLPLANE:
continue
Expand All @@ -144,6 +155,23 @@ class ControlPlaneAclManager(object):
if rule_table_name == table_name:
acl_rules[rule_props["PRIORITY"]] = rule_props

# If we haven't determined the IP version for this ACL table yet,
# try to do it now. We determine heuristically based on whether the
# src IP is an IPv4 or IPv6 address.
if not table_ip_version and "SRC_IP" in rule_props and rule_props["SRC_IP"]:
ip_addr = ipaddress.IPAddress(rule_props["SRC_IP"].split("/")[0])
if isinstance(ip_addr, ipaddress.IPv6Address):
table_ip_version = 6
elif isinstance(ip_addr, ipaddress.IPv4Address):
table_ip_version = 4

# If we were unable to determine whether this ACL table contains
# IPv4 or IPv6 rules, log a message and skip processing this table.
if not table_ip_version:
log_warning("Unable to determine if ACL table '{}' contains IPv4 or IPv6 rules. Skipping table..."
.format(table_name))
continue

# For each ACL rule in this table (in descending order of priority)
for priority in sorted(acl_rules.iterkeys(), reverse=True):
rule_props = acl_rules[priority]
Expand All @@ -155,7 +183,8 @@ class ControlPlaneAclManager(object):
# Apply the rule to the default protocol(s) for this ACL service
for ip_protocol in ip_protocols:
for dst_port in dst_ports:
rule_cmd = "iptables -A INPUT -p {}".format(ip_protocol)
rule_cmd = "ip6tables" if table_ip_version == 6 else "iptables"
rule_cmd += " -A INPUT -p {}".format(ip_protocol)

if "SRC_IP" in rule_props and rule_props["SRC_IP"]:
rule_cmd += " -s {}".format(rule_props["SRC_IP"])
Expand Down
44 changes: 4 additions & 40 deletions files/image_config/platform/rc.local
Original file line number Diff line number Diff line change
Expand Up @@ -183,51 +183,15 @@ for x in "$@"; do
done
}

setup_platform()
{
eval sonic_version=$(cat /etc/sonic/sonic_version.yml | grep build_version | cut -f2 -d" ")

if [ -f /host/image-$sonic_version/platform/firsttime ]; then

if [ -n "$aboot_platform" ]; then
platform=$aboot_platform
elif [ -n "$onie_platform" ]; then
platform=$onie_platform
else
platform=''
fi
}

# Setup default values in this function before reading installer.conf
# installer.conf could override the value set in this function.
setup_platform_defaults()
{
# Default serial port: ttyS0
CONSOLE_DEV=0
}

load_platform_installer_config()
{
INSTALLER_CFG=/usr/share/sonic/device/$platform/installer.conf
if [ -f $INSTALLER_CFG ]; then
. $INSTALLER_CFG
fi
}

program_serial_port()
{
sed -i "s|ttyS.|ttyS$CONSOLE_DEV|g" /etc/systemd/system/serial-port-watchdog.service
systemctl daemon-reload
systemctl restart serial-port-watchdog.service
}

eval sonic_version=$(cat /etc/sonic/sonic_version.yml | grep build_version | cut -f2 -d" ")

setup_platform
setup_platform_defaults
load_platform_installer_config

program_serial_port

if [ -f /host/image-$sonic_version/platform/firsttime ]; then

if [ -z "$platform" ]; then
echo "Unknown sonic platform"
firsttime_exit
fi
Expand Down
Loading

0 comments on commit 260730a

Please sign in to comment.