Hi, all:
Recently I found a paragraph of codes about routing extension header in IPv6
which confused me.
Could someone give me a hint? Thanks.
Below is the code between line 611 and line 637 in fil.c, frpr_routing6() is
used to handle the routing extension header of IPv6 packet.
I have questions here.
It seems that fin->fin_dp (line 620) here is used to get "the length of routing
extension header (shift)" to check if there is "nasty extension header length"
or not.
But fin->fin_dp in code is pointed to next extension header after routing
extension header since fin->fin_dp is changed in frpr_ipv6exthdr().
Or is there any RFCs specifics that the next header after routing extension
header MUST
1. longer than 40 bytes? // ((shift < sizeof(struct ip6_hdr))
2. aligned on four bits? // ((shift - sizeof(struct ip6_hdr)) & 15))
static INLINE int frpr_routing6(fin)
fr_info_t *fin;
{
struct ip6_ext *hdr;
int shift;
if (frpr_ipv6exthdr(fin, 0, IPPROTO_ROUTING) == IPPROTO_NONE)
return IPPROTO_NONE;
hdr = fin->fin_dp; // line 620
shift = 8 + (hdr->ip6e_len << 3);
/*
* Nasty extension header length?
*/
if ((shift < sizeof(struct ip6_hdr)) ||
((shift - sizeof(struct ip6_hdr)) & 15)) {
fin->fin_flx |= FI_BAD;
/*
* Compensate for the changes made in frpr_ipv6exthdr()
*/
fin->fin_dlen += shift;
fin->fin_dp = (char *)fin->fin_dp - shift;
return IPPROTO_NONE;
}
return hdr->ip6e_nxt;
}
Sincerely,
Y.T.