From 3186faf665f3c8f1a78677762f45fd0457784772 Mon Sep 17 00:00:00 2001
From: Bob Gilligan <gilligan@vyatta.com>
Date: Tue, 18 Nov 2008 17:01:36 -0800
Subject: Bugfix 3863: Provide ability to configure static ARP table entries

Add new config template tree starting at protocols.static.arp.
---
 templates/protocols/static/arp/node.def | 43 +++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)
 create mode 100644 templates/protocols/static/arp/node.def

(limited to 'templates/protocols/static/arp/node.def')

diff --git a/templates/protocols/static/arp/node.def b/templates/protocols/static/arp/node.def
new file mode 100644
index 00000000..cf028611
--- /dev/null
+++ b/templates/protocols/static/arp/node.def
@@ -0,0 +1,43 @@
+#
+# Vyatta configuration template for protocols.static.arp
+#
+# Author: Bob Gilligan (gilligan@vyatta.com)
+#
+
+tag:
+
+type: ipv4
+
+help:  Set a static ARP translation
+
+comp_help: Possible completions:
+    <ipv4>\tIPv4 destination address
+
+#
+# All the work is done here in the "end:" tag.  There are four possible cases:
+#
+#   1) A new node and possibly sub-tree with hwaddr has been created
+#   2) Value of hwaddr node in sub-tree has been changed
+#   3) The hwaddr node in sub-tree has been deleted
+#   4) This node (and hence entire sub-tree) has been deleted
+# 
+# The flow is the same in all cases.  First, we delete any
+# previous static ARP translation that may be in place for this
+# IP addr.  This will typically fail in case (1) and in case (4) if the
+# hwaddr node had been previously deleted.  Then, if a hwaddr is defined,
+# we add a new startic ARP translation for this IP addr pointing to that
+# hwaddr.  This should always succeed, so we don't try to hide error
+# messages from the user.
+# 
+# We always force a successful return in order to prevent transient
+# failures of the "arp" command from failing the commit.
+# 
+end:
+	ipaddr=$VAR(@)
+	hwaddr=$VAR(hwaddr/@)
+
+	arp -d $ipaddr > /dev/null
+	if [ -n "$hwaddr" ]; then
+	    arp -s $ipaddr $hwaddr
+	fi
+	exit 0
\ No newline at end of file
-- 
cgit v1.2.3

