gre: change gre_parse_header to return the header length
It's easier for gre_parse_header to return the header length instead of filing it into a parameter. That way, the callers that don't care about the header length can just check whether the returned value is lower than zero. In gre_err, the tunnel header must not be pulled. See commitb7f8fe251e
("gre: do not pull header in ICMP error processing") for details. This patch reduces the conflict between the mentioned commit and commit95f5c64c3c
("gre: Move utility functions to common headers"). Signed-off-by: Jiri Benc <jbenc@redhat.com> Acked-by: Tom Herbert <tom@herbertland.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Родитель
d4011239f4
Коммит
f132ae7c46
|
@ -26,7 +26,7 @@ int gre_del_protocol(const struct gre_protocol *proto, u8 version);
|
||||||
struct net_device *gretap_fb_dev_create(struct net *net, const char *name,
|
struct net_device *gretap_fb_dev_create(struct net *net, const char *name,
|
||||||
u8 name_assign_type);
|
u8 name_assign_type);
|
||||||
int gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,
|
int gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,
|
||||||
bool *csum_err, int *hdr_len);
|
bool *csum_err);
|
||||||
|
|
||||||
static inline int gre_calc_hlen(__be16 o_flags)
|
static inline int gre_calc_hlen(__be16 o_flags)
|
||||||
{
|
{
|
||||||
|
|
|
@ -60,8 +60,9 @@ int gre_del_protocol(const struct gre_protocol *proto, u8 version)
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(gre_del_protocol);
|
EXPORT_SYMBOL_GPL(gre_del_protocol);
|
||||||
|
|
||||||
|
/* Fills in tpi and returns header length to be pulled. */
|
||||||
int gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,
|
int gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,
|
||||||
bool *csum_err, int *ret_hdr_len)
|
bool *csum_err)
|
||||||
{
|
{
|
||||||
const struct gre_base_hdr *greh;
|
const struct gre_base_hdr *greh;
|
||||||
__be32 *options;
|
__be32 *options;
|
||||||
|
@ -119,8 +120,7 @@ int gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*ret_hdr_len = hdr_len;
|
return hdr_len;
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(gre_parse_header);
|
EXPORT_SYMBOL(gre_parse_header);
|
||||||
|
|
||||||
|
|
|
@ -221,16 +221,12 @@ static void gre_err(struct sk_buff *skb, u32 info)
|
||||||
const int code = icmp_hdr(skb)->code;
|
const int code = icmp_hdr(skb)->code;
|
||||||
struct tnl_ptk_info tpi;
|
struct tnl_ptk_info tpi;
|
||||||
bool csum_err = false;
|
bool csum_err = false;
|
||||||
int hdr_len;
|
|
||||||
|
|
||||||
if (gre_parse_header(skb, &tpi, &csum_err, &hdr_len)) {
|
if (gre_parse_header(skb, &tpi, &csum_err) < 0) {
|
||||||
if (!csum_err) /* ignore csum errors. */
|
if (!csum_err) /* ignore csum errors. */
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (iptunnel_pull_header(skb, hdr_len, tpi.proto, false))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (type == ICMP_DEST_UNREACH && code == ICMP_FRAG_NEEDED) {
|
if (type == ICMP_DEST_UNREACH && code == ICMP_FRAG_NEEDED) {
|
||||||
ipv4_update_pmtu(skb, dev_net(skb->dev), info,
|
ipv4_update_pmtu(skb, dev_net(skb->dev), info,
|
||||||
skb->dev->ifindex, 0, IPPROTO_GRE, 0);
|
skb->dev->ifindex, 0, IPPROTO_GRE, 0);
|
||||||
|
@ -314,7 +310,8 @@ static int gre_rcv(struct sk_buff *skb)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (gre_parse_header(skb, &tpi, &csum_err, &hdr_len) < 0)
|
hdr_len = gre_parse_header(skb, &tpi, &csum_err);
|
||||||
|
if (hdr_len < 0)
|
||||||
goto drop;
|
goto drop;
|
||||||
|
|
||||||
if (iptunnel_pull_header(skb, hdr_len, tpi.proto, false))
|
if (iptunnel_pull_header(skb, hdr_len, tpi.proto, false))
|
||||||
|
|
|
@ -468,7 +468,8 @@ static int gre_rcv(struct sk_buff *skb)
|
||||||
bool csum_err = false;
|
bool csum_err = false;
|
||||||
int hdr_len;
|
int hdr_len;
|
||||||
|
|
||||||
if (gre_parse_header(skb, &tpi, &csum_err, &hdr_len) < 0)
|
hdr_len = gre_parse_header(skb, &tpi, &csum_err);
|
||||||
|
if (hdr_len < 0)
|
||||||
goto drop;
|
goto drop;
|
||||||
|
|
||||||
if (iptunnel_pull_header(skb, hdr_len, tpi.proto, false))
|
if (iptunnel_pull_header(skb, hdr_len, tpi.proto, false))
|
||||||
|
|
Загрузка…
Ссылка в новой задаче