#!/bin/sh

reorder_layerscape_interfaces() {
	if [ ! -f /tmp/sysinfo/board_name ]; then
		echo "No board name found, not doing reorder_layerscape_interfaces"
		return 0
	fi

	board=$(cat /tmp/sysinfo/board_name)
	case "$board" in
	"traverse,ls1043v" | \
	"traverse,ls1043s")

		# Reorder ethernet interfaces to match the physical order
		ip link set eth2 name fm1-mac3
		ip link set eth4 name eth2
		ip link set eth3 name fm1-mac4
		ip link set eth5 name eth3
		ip link set fm1-mac3 name eth4
		ip link set fm1-mac4 name eth5
		;;
	default)
		echo "Unknown board $board"
		;;
	esac
}

boot_hook_add preinit_main reorder_layerscape_interfaces
