Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 314696
b: refs/heads/master
c: 0354440
h: refs/heads/master
v: v3
  • Loading branch information
Sven Eckelmann authored and Antonio Quartulli committed Jun 28, 2012
1 parent 766e8fc commit 1c72073
Show file tree
Hide file tree
Showing 13 changed files with 82 additions and 87 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 41347dcdd81988b8e60853257b2875285cc17a4e
refs/heads/master: 0354440ba142eb9b6a03d287349350c1f75e5786
5 changes: 2 additions & 3 deletions trunk/include/net/ip.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,8 @@ static inline __u8 ip_reply_arg_flowi_flags(const struct ip_reply_arg *arg)
return (arg->flags & IP_REPLY_ARG_NOSRCCHECK) ? FLOWI_FLAG_ANYSRC : 0;
}

void ip_send_unicast_reply(struct sock *sk, struct sk_buff *skb, __be32 daddr,
__be32 saddr, const struct ip_reply_arg *arg,
unsigned int len);
void ip_send_reply(struct sock *sk, struct sk_buff *skb, __be32 daddr,
const struct ip_reply_arg *arg, unsigned int len);

struct ipv4_config {
int log_martians;
Expand Down
3 changes: 1 addition & 2 deletions trunk/include/net/ip_fib.h
Original file line number Diff line number Diff line change
Expand Up @@ -230,10 +230,9 @@ extern struct fib_table *fib_get_table(struct net *net, u32 id);
/* Exported by fib_frontend.c */
extern const struct nla_policy rtm_ipv4_policy[];
extern void ip_fib_init(void);
extern __be32 fib_compute_spec_dst(struct sk_buff *skb);
extern int fib_validate_source(struct sk_buff *skb, __be32 src, __be32 dst,
u8 tos, int oif, struct net_device *dev,
u32 *itag);
__be32 *spec_dst, u32 *itag);
extern void fib_select_default(struct fib_result *res);

/* Exported by fib_semantics.c */
Expand Down
1 change: 1 addition & 0 deletions trunk/include/net/route.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ struct rtable {
__be32 rt_gateway;

/* Miscellaneous cached information */
__be32 rt_spec_dst; /* RFC1122 specific destination */
u32 rt_peer_genid;
unsigned long _peer; /* long-living peer info */
struct fib_info *fi; /* for client ref to shared metrics */
Expand Down
29 changes: 16 additions & 13 deletions trunk/net/batman-adv/unicast.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@
#include "hard-interface.h"


static struct sk_buff *frag_merge_packet(struct list_head *head,
struct frag_packet_list_entry *tfp,
struct sk_buff *skb)
static struct sk_buff *
batadv_frag_merge_packet(struct list_head *head,
struct frag_packet_list_entry *tfp,
struct sk_buff *skb)
{
struct unicast_frag_packet *up =
(struct unicast_frag_packet *)skb->data;
Expand Down Expand Up @@ -75,7 +76,8 @@ static struct sk_buff *frag_merge_packet(struct list_head *head,
return NULL;
}

static void frag_create_entry(struct list_head *head, struct sk_buff *skb)
static void batadv_frag_create_entry(struct list_head *head,
struct sk_buff *skb)
{
struct frag_packet_list_entry *tfp;
struct unicast_frag_packet *up =
Expand All @@ -91,7 +93,7 @@ static void frag_create_entry(struct list_head *head, struct sk_buff *skb)
return;
}

static int frag_create_buffer(struct list_head *head)
static int batadv_frag_create_buffer(struct list_head *head)
{
int i;
struct frag_packet_list_entry *tfp;
Expand All @@ -111,8 +113,9 @@ static int frag_create_buffer(struct list_head *head)
return 0;
}

static struct frag_packet_list_entry *frag_search_packet(struct list_head *head,
const struct unicast_frag_packet *up)
static struct frag_packet_list_entry *
batadv_frag_search_packet(struct list_head *head,
const struct unicast_frag_packet *up)
{
struct frag_packet_list_entry *tfp;
struct unicast_frag_packet *tmp_up = NULL;
Expand Down Expand Up @@ -188,22 +191,22 @@ int batadv_frag_reassemble_skb(struct sk_buff *skb, struct bat_priv *bat_priv,
orig_node->last_frag_packet = jiffies;

if (list_empty(&orig_node->frag_list) &&
frag_create_buffer(&orig_node->frag_list)) {
batadv_frag_create_buffer(&orig_node->frag_list)) {
pr_debug("couldn't create frag buffer\n");
goto out;
}

tmp_frag_entry = frag_search_packet(&orig_node->frag_list,
unicast_packet);
tmp_frag_entry = batadv_frag_search_packet(&orig_node->frag_list,
unicast_packet);

if (!tmp_frag_entry) {
frag_create_entry(&orig_node->frag_list, skb);
batadv_frag_create_entry(&orig_node->frag_list, skb);
ret = NET_RX_SUCCESS;
goto out;
}

*new_skb = frag_merge_packet(&orig_node->frag_list, tmp_frag_entry,
skb);
*new_skb = batadv_frag_merge_packet(&orig_node->frag_list,
tmp_frag_entry, skb);
/* if not, merge failed */
if (*new_skb)
ret = NET_RX_SUCCESS;
Expand Down
38 changes: 7 additions & 31 deletions trunk/net/ipv4/fib_frontend.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,35 +180,6 @@ unsigned int inet_dev_addr_type(struct net *net, const struct net_device *dev,
}
EXPORT_SYMBOL(inet_dev_addr_type);

__be32 fib_compute_spec_dst(struct sk_buff *skb)
{
struct net_device *dev = skb->dev;
struct in_device *in_dev;
struct fib_result res;
struct flowi4 fl4;
struct net *net;

if (skb->pkt_type != PACKET_BROADCAST &&
skb->pkt_type != PACKET_MULTICAST)
return ip_hdr(skb)->daddr;

in_dev = __in_dev_get_rcu(dev);
BUG_ON(!in_dev);
fl4.flowi4_oif = 0;
fl4.flowi4_iif = 0;
fl4.daddr = ip_hdr(skb)->saddr;
fl4.saddr = ip_hdr(skb)->daddr;
fl4.flowi4_tos = RT_TOS(ip_hdr(skb)->tos);
fl4.flowi4_scope = RT_SCOPE_UNIVERSE;
fl4.flowi4_mark = IN_DEV_SRC_VMARK(in_dev) ? skb->mark : 0;

net = dev_net(dev);
if (!fib_lookup(net, &fl4, &res))
return FIB_RES_PREFSRC(net, res);
else
return inet_select_addr(dev, 0, RT_SCOPE_UNIVERSE);
}

/* Given (packet source, input interface) and optional (dst, oif, tos):
* - (main) check, that source is valid i.e. not broadcast or our local
* address.
Expand All @@ -218,7 +189,8 @@ __be32 fib_compute_spec_dst(struct sk_buff *skb)
* called with rcu_read_lock()
*/
int fib_validate_source(struct sk_buff *skb, __be32 src, __be32 dst, u8 tos,
int oif, struct net_device *dev, u32 *itag)
int oif, struct net_device *dev, __be32 *spec_dst,
u32 *itag)
{
struct in_device *in_dev;
struct flowi4 fl4;
Expand Down Expand Up @@ -257,6 +229,7 @@ int fib_validate_source(struct sk_buff *skb, __be32 src, __be32 dst, u8 tos,
if (res.type != RTN_LOCAL || !accept_local)
goto e_inval;
}
*spec_dst = FIB_RES_PREFSRC(net, res);
fib_combine_itag(itag, &res);
dev_match = false;

Expand Down Expand Up @@ -285,14 +258,17 @@ int fib_validate_source(struct sk_buff *skb, __be32 src, __be32 dst, u8 tos,

ret = 0;
if (fib_lookup(net, &fl4, &res) == 0) {
if (res.type == RTN_UNICAST)
if (res.type == RTN_UNICAST) {
*spec_dst = FIB_RES_PREFSRC(net, res);
ret = FIB_RES_NH(res).nh_scope >= RT_SCOPE_HOST;
}
}
return ret;

last_resort:
if (rpf)
goto e_rpf;
*spec_dst = inet_select_addr(dev, 0, RT_SCOPE_UNIVERSE);
*itag = 0;
return 0;

Expand Down
6 changes: 2 additions & 4 deletions trunk/net/ipv4/icmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@
#include <net/checksum.h>
#include <net/xfrm.h>
#include <net/inet_common.h>
#include <net/ip_fib.h>

/*
* Build xmit assembly blocks
Expand Down Expand Up @@ -334,7 +333,7 @@ static void icmp_reply(struct icmp_bxm *icmp_param, struct sk_buff *skb)
struct flowi4 fl4;
struct sock *sk;
struct inet_sock *inet;
__be32 daddr, saddr;
__be32 daddr;

if (ip_options_echo(&icmp_param->replyopts.opt.opt, skb))
return;
Expand All @@ -348,7 +347,6 @@ static void icmp_reply(struct icmp_bxm *icmp_param, struct sk_buff *skb)

inet->tos = ip_hdr(skb)->tos;
daddr = ipc.addr = ip_hdr(skb)->saddr;
saddr = fib_compute_spec_dst(skb);
ipc.opt = NULL;
ipc.tx_flags = 0;
if (icmp_param->replyopts.opt.opt.optlen) {
Expand All @@ -358,7 +356,7 @@ static void icmp_reply(struct icmp_bxm *icmp_param, struct sk_buff *skb)
}
memset(&fl4, 0, sizeof(fl4));
fl4.daddr = daddr;
fl4.saddr = saddr;
fl4.saddr = rt->rt_spec_dst;
fl4.flowi4_tos = RT_TOS(ip_hdr(skb)->tos);
fl4.flowi4_proto = IPPROTO_ICMP;
security_skb_classify_flow(skb, flowi4_to_flowi(&fl4));
Expand Down
22 changes: 11 additions & 11 deletions trunk/net/ipv4/ip_options.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
#include <net/icmp.h>
#include <net/route.h>
#include <net/cipso_ipv4.h>
#include <net/ip_fib.h>

/*
* Write options to IP header, record destination address to
Expand Down Expand Up @@ -105,7 +104,7 @@ int ip_options_echo(struct ip_options *dopt, struct sk_buff *skb)
sptr = skb_network_header(skb);
dptr = dopt->__data;

daddr = fib_compute_spec_dst(skb);
daddr = skb_rtable(skb)->rt_spec_dst;

if (sopt->rr) {
optlen = sptr[sopt->rr+1];
Expand Down Expand Up @@ -251,14 +250,15 @@ void ip_options_fragment(struct sk_buff *skb)
int ip_options_compile(struct net *net,
struct ip_options *opt, struct sk_buff *skb)
{
__be32 spec_dst = (__force __be32) 0;
unsigned char *pp_ptr = NULL;
unsigned char *optptr;
int l;
unsigned char *iph;
int optlen, l;
unsigned char *optptr;
int optlen;
unsigned char *pp_ptr = NULL;
struct rtable *rt = NULL;

if (skb != NULL) {
spec_dst = fib_compute_spec_dst(skb);
rt = skb_rtable(skb);
optptr = (unsigned char *)&(ip_hdr(skb)[1]);
} else
optptr = opt->__data;
Expand Down Expand Up @@ -330,8 +330,8 @@ int ip_options_compile(struct net *net,
pp_ptr = optptr + 2;
goto error;
}
if (skb) {
memcpy(&optptr[optptr[2]-1], &spec_dst, 4);
if (rt) {
memcpy(&optptr[optptr[2]-1], &rt->rt_spec_dst, 4);
opt->is_changed = 1;
}
optptr[2] += 4;
Expand Down Expand Up @@ -372,8 +372,8 @@ int ip_options_compile(struct net *net,
goto error;
}
opt->ts = optptr - iph;
if (skb) {
memcpy(&optptr[optptr[2]-1], &spec_dst, 4);
if (rt) {
memcpy(&optptr[optptr[2]-1], &rt->rt_spec_dst, 4);
timeptr = &optptr[optptr[2]+3];
}
opt->ts_needaddr = 1;
Expand Down
9 changes: 4 additions & 5 deletions trunk/net/ipv4/ip_output.c
Original file line number Diff line number Diff line change
Expand Up @@ -1459,14 +1459,13 @@ static int ip_reply_glue_bits(void *dptr, char *to, int offset,

/*
* Generic function to send a packet as reply to another packet.
* Used to send TCP resets so far.
* Used to send TCP resets so far. ICMP should use this function too.
*
* Should run single threaded per socket because it uses the sock
* structure to pass arguments.
*/
void ip_send_unicast_reply(struct sock *sk, struct sk_buff *skb, __be32 daddr,
__be32 saddr, const struct ip_reply_arg *arg,
unsigned int len)
void ip_send_reply(struct sock *sk, struct sk_buff *skb, __be32 daddr,
const struct ip_reply_arg *arg, unsigned int len)
{
struct inet_sock *inet = inet_sk(sk);
struct ip_options_data replyopts;
Expand All @@ -1492,7 +1491,7 @@ void ip_send_unicast_reply(struct sock *sk, struct sk_buff *skb, __be32 daddr,
RT_TOS(arg->tos),
RT_SCOPE_UNIVERSE, sk->sk_protocol,
ip_reply_arg_flowi_flags(arg),
daddr, saddr,
daddr, rt->rt_spec_dst,
tcp_hdr(skb)->source, tcp_hdr(skb)->dest);
security_skb_classify_flow(skb, flowi4_to_flowi(&fl4));
rt = ip_route_output_key(sock_net(sk), &fl4);
Expand Down
7 changes: 3 additions & 4 deletions trunk/net/ipv4/ip_sockglue.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
#if IS_ENABLED(CONFIG_IPV6)
#include <net/transp_v6.h>
#endif
#include <net/ip_fib.h>

#include <linux/errqueue.h>
#include <asm/uaccess.h>
Expand Down Expand Up @@ -1020,8 +1019,8 @@ static int do_ip_setsockopt(struct sock *sk, int level,
* @sk: socket
* @skb: buffer
*
* To support IP_CMSG_PKTINFO option, we store rt_iif and specific
* destination in skb->cb[] before dst drop.
* To support IP_CMSG_PKTINFO option, we store rt_iif and rt_spec_dst
* in skb->cb[] before dst drop.
* This way, receiver doesnt make cache line misses to read rtable.
*/
void ipv4_pktinfo_prepare(struct sk_buff *skb)
Expand All @@ -1031,7 +1030,7 @@ void ipv4_pktinfo_prepare(struct sk_buff *skb)

if (rt) {
pktinfo->ipi_ifindex = rt->rt_iif;
pktinfo->ipi_spec_dst.s_addr = fib_compute_spec_dst(skb);
pktinfo->ipi_spec_dst.s_addr = rt->rt_spec_dst;
} else {
pktinfo->ipi_ifindex = 0;
pktinfo->ipi_spec_dst.s_addr = 0;
Expand Down
Loading

0 comments on commit 1c72073

Please sign in to comment.