From: Adam Seering <adam@seering.org>
To: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>,
netdev@vger.kernel.org
Subject: [PATCH] appletalk: Pass IP-over-DDP packets through when 'ipddp0' interface is not present
Date: Thu, 14 Jan 2016 23:40:47 -0500 [thread overview]
Message-ID: <1452832847.1707.42.camel@seering.org> (raw)
Let userspace programs transmit and receive raw IP-over-DDP packets
with a kernel where "ipddp" was compiled as a module but is not loaded
(so no "ipddp0" network interface is exposed). This makes the "module
is unloaded" behavior match the "module was never compiled" behavior.
Signed-off-by: Adam Seering <adam@seering.org>
---
This is a small proposed change to the ddp code. It's also my first attempt at a kernel patch; I'd appreciate any feedback or discussion. I'm working on the Linux "macipgw" port; it duplicates some functionality of the "ipddp" module, but the latter depends on userspace utilities which I can no longer find up-to-date working copies of?
diff --git a/net/appletalk/ddp.c b/net/appletalk/ddp.c
index d5871ac..d30e55f 100644
--- a/net/appletalk/ddp.c
+++ b/net/appletalk/ddp.c
@@ -1284,17 +1284,10 @@ static __inline__ int is_ip_over_ddp(struct sk_buff *skb)
return skb->data[12] == 22;
}
-static int handle_ip_over_ddp(struct sk_buff *skb)
+static int handle_ip_over_ddp(struct sk_buff *skb, struct net_device *dev)
{
- struct net_device *dev = __dev_get_by_name(&init_net, "ipddp0");
struct net_device_stats *stats;
- /* This needs to be able to handle ipddp"N" devices */
- if (!dev) {
- kfree_skb(skb);
- return NET_RX_DROP;
- }
-
skb->protocol = htons(ETH_P_IP);
skb_pull(skb, 13);
skb->dev = dev;
@@ -1308,7 +1301,7 @@ static int handle_ip_over_ddp(struct sk_buff *skb)
#else
/* make it easy for gcc to optimize this test out, i.e. kill the code */
#define is_ip_over_ddp(skb) 0
-#define handle_ip_over_ddp(skb) 0
+#define handle_ip_over_ddp(skb, dev) 0
#endif
static int atalk_route_packet(struct sk_buff *skb, struct net_device *dev,
@@ -1418,6 +1411,8 @@ static int atalk_rcv(struct sk_buff *skb, struct net_device *dev,
struct sock *sock;
struct atalk_iface *atif;
struct sockaddr_at tosat;
+ struct net_device *ipddp_dev;
+
int origlen;
__u16 len_hops;
@@ -1473,9 +1468,14 @@ static int atalk_rcv(struct sk_buff *skb, struct net_device *dev,
return atalk_route_packet(skb, dev, ddp, len_hops, origlen);
}
- /* if IP over DDP is not selected this code will be optimized out */
- if (is_ip_over_ddp(skb))
- return handle_ip_over_ddp(skb);
+ /* if IP over DDP is not selected this code should be optimized out */
+ if (is_ip_over_ddp(skb)) {
+ ipddp_dev = __dev_get_by_name(&init_net, "ipddp0");
+
+ /* This needs to be able to handle ipddp"N" devices */
+ if (ipddp_dev)
+ return handle_ip_over_ddp(skb, ipddp_dev);
+ }
/*
* Which socket - atalk_search_socket() looks for a *full match*
* of the <net, node, port> tuple.
next reply other threads:[~2016-01-15 4:49 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-15 4:40 Adam Seering [this message]
2016-01-18 0:25 ` [PATCH] appletalk: Pass IP-over-DDP packets through when 'ipddp0' interface is not present David Miller
2016-01-18 1:16 ` Adam Seering
2016-01-18 5:04 ` David Miller
-- strict thread matches above, loose matches on Subject: below --
2016-02-23 14:19 Adam Seering
2016-02-25 19:33 ` David Miller
2016-02-26 0:46 ` Adam Seering
2016-02-27 4:49 ` Adam Seering
2016-03-20 21:19 ` Adam Seering
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1452832847.1707.42.camel@seering.org \
--to=adam@seering.org \
--cc=acme@ghostprotocols.net \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).