Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 341632
b: refs/heads/master
c: 9195bb8
h: refs/heads/master
v: v3
  • Loading branch information
Ansis Atteka authored and Jesse Gross committed Nov 12, 2012
1 parent 09ad6d3 commit d49f952
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 11 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: f8f626754ebeca613cf1af2e6f890cfde0e74d5b
refs/heads/master: 9195bb8e381d81d5a315f911904cdf0cfcc919b8
5 changes: 3 additions & 2 deletions trunk/include/net/ipv6.h
Original file line number Diff line number Diff line change
Expand Up @@ -631,8 +631,9 @@ extern int ipv6_skip_exthdr(const struct sk_buff *, int start,
extern bool ipv6_ext_hdr(u8 nexthdr);

enum {
IP6_FH_F_FRAG = (1 << 0),
IP6_FH_F_AUTH = (1 << 1),
IP6_FH_F_FRAG = (1 << 0),
IP6_FH_F_AUTH = (1 << 1),
IP6_FH_F_SKIP_RH = (1 << 2),
};

/* find specified header and get offset to it */
Expand Down
36 changes: 28 additions & 8 deletions trunk/net/ipv6/exthdrs_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,16 +132,19 @@ EXPORT_SYMBOL(ipv6_skip_exthdr);
* *offset is meaningless and fragment offset is stored in *fragoff if fragoff
* isn't NULL.
*
* if flags is not NULL and it's a fragment, then the frag flag IP6_FH_F_FRAG
* will be set. If it's an AH header, the IP6_FH_F_AUTH flag is set and
* target < 0, then this function will stop at the AH header.
* if flags is not NULL and it's a fragment, then the frag flag
* IP6_FH_F_FRAG will be set. If it's an AH header, the
* IP6_FH_F_AUTH flag is set and target < 0, then this function will
* stop at the AH header. If IP6_FH_F_SKIP_RH flag was passed, then this
* function will skip all those routing headers, where segements_left was 0.
*/
int ipv6_find_hdr(const struct sk_buff *skb, unsigned int *offset,
int target, unsigned short *fragoff, int *flags)
{
unsigned int start = skb_network_offset(skb) + sizeof(struct ipv6hdr);
u8 nexthdr = ipv6_hdr(skb)->nexthdr;
unsigned int len;
bool found;

if (fragoff)
*fragoff = 0;
Expand All @@ -159,9 +162,10 @@ int ipv6_find_hdr(const struct sk_buff *skb, unsigned int *offset,
}
len = skb->len - start;

while (nexthdr != target) {
do {
struct ipv6_opt_hdr _hdr, *hp;
unsigned int hdrlen;
found = (nexthdr == target);

if ((!ipv6_ext_hdr(nexthdr)) || nexthdr == NEXTHDR_NONE) {
if (target < 0)
Expand All @@ -172,6 +176,20 @@ int ipv6_find_hdr(const struct sk_buff *skb, unsigned int *offset,
hp = skb_header_pointer(skb, start, sizeof(_hdr), &_hdr);
if (hp == NULL)
return -EBADMSG;

if (nexthdr == NEXTHDR_ROUTING) {
struct ipv6_rt_hdr _rh, *rh;

rh = skb_header_pointer(skb, start, sizeof(_rh),
&_rh);
if (rh == NULL)
return -EBADMSG;

if (flags && (*flags & IP6_FH_F_SKIP_RH) &&
rh->segments_left == 0)
found = false;
}

if (nexthdr == NEXTHDR_FRAGMENT) {
unsigned short _frag_off;
__be16 *fp;
Expand Down Expand Up @@ -205,10 +223,12 @@ int ipv6_find_hdr(const struct sk_buff *skb, unsigned int *offset,
} else
hdrlen = ipv6_optlen(hp);

nexthdr = hp->nexthdr;
len -= hdrlen;
start += hdrlen;
}
if (!found) {
nexthdr = hp->nexthdr;
len -= hdrlen;
start += hdrlen;
}
} while (!found);

*offset = start;
return nexthdr;
Expand Down

0 comments on commit d49f952

Please sign in to comment.