This patch enables ARP support for the RT-Proxy Linux device.
Incoming ARP replys are delivered to both, the RTnet and the
Linux network stack. The RT-Proxy then gets attached to the
corresponding RTnet device, rteth0 by default. Currently only
one RT-Proxy device is supported. This feature can be enabled
with the configure option "--enable-proxy-arp" or the Kconfig
option CONFIG_RTNET_ADDON_PROXY_ARP.
Note: this patch requires running "scripts/autogen.sh"
Signed-off-by: Wolfang Grandegger <[EMAIL PROTECTED]>
Index: rtnet/stack/ipv4/arp.c
===================================================================
--- rtnet.orig/stack/ipv4/arp.c
+++ rtnet/stack/ipv4/arp.c
@@ -25,6 +25,9 @@
#include <stack_mgr.h>
#include <ipv4/arp.h>
+#ifdef CONFIG_RTNET_ADDON_PROXY_ARP
+#include <ipv4/ip_input.h>
+#endif /* CONFIG_RTNET_ADDON_PROXY_ARP */
/***
* arp_send: Create and send an arp packet. If (dest_hw == NULL),
@@ -168,12 +171,20 @@ int rt_arp_rcv(struct rtskb *skb, struct
if (tip == rtdev->local_ip) {
rt_ip_route_add_host(sip, sha, rtdev);
+#ifndef CONFIG_RTNET_ADDON_PROXY_ARP
if (arp->ar_op == __constant_htons(ARPOP_REQUEST))
rt_arp_send(ARPOP_REPLY, ETH_P_ARP, sip, rtdev, tip, sha,
rtdev->dev_addr, sha);
+#endif /* CONFIG_RTNET_ADDON_PROXY_ARP */
}
out:
+#ifdef CONFIG_RTNET_ADDON_PROXY_ARP
+ if (rt_ip_fallback_handler) {
+ rt_ip_fallback_handler(skb);
+ return 0;
+ }
+#endif /* CONFIG_RTNET_ADDON_PROXY_ARP */
kfree_rtskb(skb);
return 0;
}
Index: rtnet/addons/rtnetproxy.c
===================================================================
--- rtnet.orig/addons/rtnetproxy.c
+++ rtnet/addons/rtnetproxy.c
@@ -105,6 +105,14 @@ static rtdm_task_t rtnetproxy_thread;
static rtdm_sem_t rtnetproxy_sem;
+#ifdef CONFIG_RTNET_ADDON_PROXY_ARP
+static char* rtdev_attach = "rteth0";
+module_param(rtdev_attach, charp, 0444);
+MODULE_PARM_DESC(rtdev_attach, "Attach to the specified RTnet device");
+
+struct rtnet_device *rtnetproxy_rtdev;
+#endif
+
/* ***********************************************************************
* Returns the next pointer from the ringbuffer or zero if nothing is
* available
@@ -181,7 +189,10 @@ static inline void send_data_out(struct
{
struct rtskb *rtskb;
+#ifndef CONFIG_RTNET_ADDON_PROXY_ARP
struct dest_route rt;
+ int rc;
+#endif
struct skb_data_format
{
@@ -194,7 +205,6 @@ static inline void send_data_out(struct
* thus no spaces are allowed! */
struct skb_data_format *pData;
- int rc;
/* Copy the data from the standard sk_buff to the realtime sk_buff:
* Both have the same length. */
@@ -208,6 +218,17 @@ static inline void send_data_out(struct
pData = (struct skb_data_format*) rtskb->data;
+#ifdef CONFIG_RTNET_ADDON_PROXY_ARP
+ rtdev_reference(rtnetproxy_rtdev);
+
+ rtskb->rtdev = rtnetproxy_rtdev;
+
+ /* Call the actual transmit function */
+ rtdev_xmit_proxy(rtskb);
+
+ rtdev_dereference(rtnetproxy_rtdev);
+
+#else /* !CONFIG_RTNET_ADDON_PROXY_ARP */
/* Determine the device to use: Only ip routing is used here.
* Non-ip protocols are not supported... */
rc = rt_ip_route_output(&rt, pData->ip_dst, INADDR_ANY);
@@ -244,6 +265,7 @@ static inline void send_data_out(struct
kfree_rtskb(rtskb);
}
+#endif /* CONFIG_RTNET_ADDON_PROXY_ARP */
}
/* ************************************************************************
@@ -456,7 +478,11 @@ static int __init rtnetproxy_init(struct
/* Fill in device structure with ethernet-generic values. */
ether_setup(dev);
dev->tx_queue_len = 0;
+#ifdef CONFIG_RTNET_ADDON_PROXY_ARP
+ memcpy(dev->dev_addr, rtnetproxy_rtdev->dev_addr, sizeof(dev->dev_addr));
+#else
dev->flags |= IFF_NOARP;
+#endif
dev->flags &= ~IFF_MULTICAST;
return 0;
@@ -479,6 +505,15 @@ static int __init rtnetproxy_init_module
{
int err;
+#ifdef CONFIG_RTNET_ADDON_PROXY_ARP
+ if ((rtnetproxy_rtdev = rtdev_get_by_name(rtdev_attach)) == NULL) {
+ printk("Couldn't attach to %s\n", rtdev_attach);
+ return -EINVAL;
+ }
+ rtdev_dereference(rtnetproxy_rtdev);
+ printk("RTproxy attached to %s\n", rtdev_attach);
+#endif
+
/* Initialize the proxy's rtskb pool (JK) */
if (rtskb_pool_init(&rtskb_pool, proxy_rtskbs) < proxy_rtskbs) {
rtskb_pool_release(&rtskb_pool);
Index: rtnet/configure.ac
===================================================================
--- rtnet.orig/configure.ac
+++ rtnet/configure.ac
@@ -1189,6 +1189,19 @@ if test "$CONFIG_RTNET_ADDON_PROXY" = "y
AC_DEFINE(CONFIG_RTNET_ADDON_PROXY,1,[rtnetproxy support])
fi
+AC_MSG_CHECKING([whether to enable rtnetproxy ARP support])
+AC_ARG_ENABLE(proxy-arp,
+ AS_HELP_STRING([--enable-proxy-arp], [enable ARP support for IP protocol
proxy driver @<:@default=no@:>@]),
+ [case "$enableval" in
+ y | yes) CONFIG_RTNET_ADDON_PROXY_ARP=y ;;
+ *) CONFIG_RTNET_ADDON_PROXY_ARP=n ;;
+ esac])
+AC_MSG_RESULT([${CONFIG_RTNET_ADDON_PROXY_ARP:-n}])
+AM_CONDITIONAL(CONFIG_RTNET_ADDON_PROXY_ARP,[test
"$CONFIG_RTNET_ADDON_PROXY_ARP" = "y"])
+if test "$CONFIG_RTNET_ADDON_PROXY_ARP" = "y"; then
+ AC_DEFINE(CONFIG_RTNET_ADDON_PROXY_ARP,1,[rtnetproxy ARP support])
+fi
+
#dnl ======================================================================
#dnl RTDM select (disabled until RTDM actually supports this)
Index: rtnet/addons/Kconfig
===================================================================
--- rtnet.orig/addons/Kconfig
+++ rtnet/addons/Kconfig
@@ -26,4 +26,14 @@ config RTNET_ADDON_PROXY
See Documentation/README.rtnetproxy for further information.
+config RTNET_ADDON_PROXY_ARP
+ bool "ARP for IP protocol proxy"
+ depends on RTNET_ADDON_PROXY
+ default n
+ ---help---
+ Enables ARP support for the IP protocol proxy. Incoming ARP replys
+ are then delivered to both, the RTnet and the Linux network stack.
+ The IP protocol proxy gets attached to the RTnet device specified
+ by the module parameter "rtdev_attach", rteth0 by default.
+
endmenu
--
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
RTnet-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rtnet-users