Skip to content

Commit

Permalink
xia: add struct net and struct sock to dst ops
Browse files Browse the repository at this point in the history
The prototype of struct dst_ops.local_out changed to include
struct net and struct sock. This patch updates XIA's output
functions to comply with these changes and to more closely
match the IP stack's prototypes for these functions. The
following patches are relevant:

  - 850dcc4
    ipv4: Fix ip_queue_xmit to pass sk into ip_local_out_sk

  - 33224b1
    ipv4, ipv6: Pass net into ip_local_out and ip6_local_out

  - cf91a99
    ipv4, ipv6: Pass net into __ip_local_out and __ip6_local_out

  - aad8872
    ipv4: add a sock pointer to dst->output() path.

  - 0c4b51f
    netfilter: Pass net into okfn

  - 7026b1d
    netfilter: Pass socket pointer down through okfn().
  • Loading branch information
cjdoucette authored and AltraMayor committed Mar 11, 2016
1 parent 1ac2cd8 commit 1695676
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 26 deletions.
6 changes: 3 additions & 3 deletions include/net/xia_output.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
#include <net/sock.h>

/* Don't call this function, prefer xip_local_out(). */
int __xip_local_out(struct sk_buff *skb);
int __xip_local_out(struct net *net, struct sock *sk, struct sk_buff *skb);

int xip_local_out(struct sk_buff *skb);
int xip_local_out(struct net *net, struct sock *sk, struct sk_buff *skb);

int xip_send_skb(struct sk_buff *skb);
int xip_send_skb(struct net *net, struct sk_buff *skb);

/* @skb must already have XIP header, and not have link layer header. */
struct sk_buff *xip_trim_packet_if_needed(struct sk_buff *skb, u32 mtu);
Expand Down
12 changes: 6 additions & 6 deletions net/xia/output.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <net/xia_socket.h>
#include <net/xia_output.h>

int __xip_local_out(struct sk_buff *skb)
int __xip_local_out(struct net *net, struct sock *sk, struct sk_buff *skb)
{
struct xiphdr *xiph = xip_hdr(skb);
int len = skb->len - xip_hdr_len(xiph);
Expand All @@ -14,16 +14,16 @@ int __xip_local_out(struct sk_buff *skb)
return 1;
}

int xip_local_out(struct sk_buff *skb)
int xip_local_out(struct net *net, struct sock *sk, struct sk_buff *skb)
{
int rc = __xip_local_out(skb);
return likely(rc == 1) ? dst_output(skb) : rc;
int rc = __xip_local_out(net, sk, skb);
return likely(rc == 1) ? dst_output(net, sk, skb) : rc;
}
EXPORT_SYMBOL_GPL(xip_local_out);

int xip_send_skb(struct sk_buff *skb)
int xip_send_skb(struct net *net, struct sk_buff *skb)
{
int rc = xip_local_out(skb);
int rc = xip_local_out(net, skb->sk, skb);
return rc > 0 ? net_xmit_errno(rc) : rc;
}
EXPORT_SYMBOL_GPL(xip_send_skb);
Expand Down
4 changes: 2 additions & 2 deletions net/xia/ppal_hid/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ static int main_input_input(struct sk_buff *skb)
/* Decrease ttl after skb cow done. */
xiph->hop_limit--;

return dst_output(skb);
return dst_output(sock_net(skb->sk), skb->sk, skb);

drop:
kfree_skb(skb);
Expand All @@ -369,7 +369,7 @@ static inline int xip_skb_dst_mtu(struct sk_buff *skb)
return dst_mtu(skb_dst(skb));
}

static int main_input_output(struct sock *sk, struct sk_buff *skb)
static int main_input_output(struct net *net, struct sock *sk, struct sk_buff *skb)
{
struct hrdw_addr *ha = skb_ha(skb);
struct net_device *dev;
Expand Down
2 changes: 1 addition & 1 deletion net/xia/ppal_u4id/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ static int handle_skb_to_ipv4(struct sock *tunnel_sk, struct sk_buff *skb,
return ip_queue_xmit(tunnel_sk, skb, flowi4_to_flowi(&fl4));
}

static int u4id_output(struct sock *sk, struct sk_buff *skb)
static int u4id_output(struct net *net, struct sock *sk, struct sk_buff *skb)
{
struct sock *tunnel_sk;
struct u4id_tunnel_dest *tunnel;
Expand Down
14 changes: 7 additions & 7 deletions net/xia/ppal_xdp/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -257,14 +257,14 @@ static int local_input_input(struct sk_buff *skb)
return -1;
}

static int local_input_output(struct sock *sk, struct sk_buff *skb)
static int local_input_output(struct net *net, struct sock *sk, struct sk_buff *skb)
{
BUG();
}

#define local_output_input local_input_input

static int local_output_output(struct sock *sk, struct sk_buff *skb)
static int local_output_output(struct net *net, struct sock *sk, struct sk_buff *skb)
{
struct net_device *dev = skb_dst(skb)->dev;

Expand All @@ -276,7 +276,7 @@ static int local_output_output(struct sock *sk, struct sk_buff *skb)
skb->protocol = __cpu_to_be16(ETH_P_XIP);

/* Deliver @skb to its socket. */
return dev_loopback_xmit(skb);
return dev_loopback_xmit(net, sk, skb);
}

static int xdp_deliver(struct xip_route_proc *rproc, struct net *net,
Expand Down Expand Up @@ -456,17 +456,17 @@ static void xdp_destroy_sock(struct sock *sk)
/* Since XDP is headerless, this function is just a wrapper for
* xip_send_skb().
*/
static inline int xdp_send_skb(struct sk_buff *skb)
static inline int xdp_send_skb(struct net *net, struct sk_buff *skb)
{
return xip_send_skb(skb);
return xip_send_skb(net, skb);
}

/* Push out all pending data as a single XDP datagram. Socket must be locked. */
static int xdp_push_pending_frames(struct sock *sk)
{
struct fib_xid_xdp_local *lxdp = sk_lxdp(sk);
struct sk_buff *skb = xip_finish_skb(sk);
int rc = !IS_ERR_OR_NULL(skb) ? xdp_send_skb(skb) : PTR_ERR(skb);
int rc = !IS_ERR_OR_NULL(skb) ? xdp_send_skb(sock_net(sk), skb) : PTR_ERR(skb);

lxdp->pending = false;
return rc;
Expand Down Expand Up @@ -659,7 +659,7 @@ static int xdp_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
else if (!skb)
rc = -SOCK_NOSPACE;
else
rc = xdp_send_skb(skb);
rc = xdp_send_skb(sock_net(sk), skb);
goto xdst;
}

Expand Down
7 changes: 3 additions & 4 deletions net/xia/ppal_zf/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ static int forward_local(struct iterate_arg *iarg,
*/
goto failed_to_forward;
}
rc = dst_output(cpy_skb);
rc = dst_output(sock_net(cpy_skb->sk), cpy_skb->sk, cpy_skb);
if (rc)
net_warn_ratelimited("XIA/ZF: can't forward a packet after digging the local ZF edge: %i\n",
rc);
Expand Down Expand Up @@ -437,7 +437,7 @@ static int forward_main(struct iterate_arg *iarg, struct fib_xid_zf_main *mzf)
kfree_skb(cpy_skb);
return 0;
}
rc = dst_output(cpy_skb);
rc = dst_output(sock_net(cpy_skb->sk), cpy_skb->sk, cpy_skb);
if (rc)
net_warn_ratelimited("XIA/ZF: can't forward a packet after routing the main ZF edge: %i\n",
rc);
Expand All @@ -463,11 +463,10 @@ static int match_xids_rcu(struct fib_xid_table *xtbl, struct fib_xid *fxid,
BUG();
}

static int zf_output(struct sock *sk, struct sk_buff *skb)
static int zf_output(struct net *net, struct sock *sk, struct sk_buff *skb)
{
struct xip_dst *xdst = skb_xdst(skb);
struct zf_dst_info *info = (struct zf_dst_info *)xdst->info;
struct net *net = xdst_net(xdst);
struct iterate_arg arg =
{.xid = info->xid, .matched = false, .forwarded_local = false,
.skb = skb, .xdst = xdst, .net = net};
Expand Down
6 changes: 3 additions & 3 deletions net/xia/route.c
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ static int xip_dst_unreachable_in(struct sk_buff *skb)
return xip_dst_unreachable("in", skb);
}

static int xip_dst_unreachable_out(struct sock *sk, struct sk_buff *skb)
static int xip_dst_unreachable_out(struct net *net, struct sock *sk, struct sk_buff *skb)
{
return xip_dst_unreachable("out", skb);
}
Expand Down Expand Up @@ -783,7 +783,7 @@ int xdst_def_hop_limit_input_method(struct sk_buff *skb)
xiph->hop_limit--;
}

return dst_output(skb);
return dst_output(sock_net(skb->sk), skb->sk, skb);

drop:
kfree_skb(skb);
Expand Down Expand Up @@ -1038,7 +1038,7 @@ static int xip_dst_not_supported_in(struct sk_buff *skb)
return xip_dst_not_supported("in", skb);
}

static int xip_dst_not_supported_out(struct sock *sk, struct sk_buff *skb)
static int xip_dst_not_supported_out(struct net *net, struct sock *sk, struct sk_buff *skb)
{
return xip_dst_not_supported("out", skb);
}
Expand Down

0 comments on commit 1695676

Please sign in to comment.