ipv6: Store Router Alert option in IP6CB directly.
Router Alert option is very small and we can store the value itself in the skb. Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
		
					parent
					
						
							
								2b464f61f0
							
						
					
				
			
			
				commit
				
					
						dd3332bfcb
					
				
			
		
					 4 changed files with 8 additions and 5 deletions
				
			
		| 
						 | 
					@ -84,7 +84,7 @@ static inline struct ipv6hdr *ipipv6_hdr(const struct sk_buff *skb)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct inet6_skb_parm {
 | 
					struct inet6_skb_parm {
 | 
				
			||||||
	int			iif;
 | 
						int			iif;
 | 
				
			||||||
	__u16			ra;
 | 
						__be16			ra;
 | 
				
			||||||
	__u16			hop;
 | 
						__u16			hop;
 | 
				
			||||||
	__u16			dst0;
 | 
						__u16			dst0;
 | 
				
			||||||
	__u16			srcrt;
 | 
						__u16			srcrt;
 | 
				
			||||||
| 
						 | 
					@ -100,6 +100,7 @@ struct inet6_skb_parm {
 | 
				
			||||||
#define IP6SKB_XFRM_TRANSFORMED	1
 | 
					#define IP6SKB_XFRM_TRANSFORMED	1
 | 
				
			||||||
#define IP6SKB_FORWARDED	2
 | 
					#define IP6SKB_FORWARDED	2
 | 
				
			||||||
#define IP6SKB_REROUTED		4
 | 
					#define IP6SKB_REROUTED		4
 | 
				
			||||||
 | 
					#define IP6SKB_ROUTERALERT	8
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define IP6CB(skb)	((struct inet6_skb_parm*)((skb)->cb))
 | 
					#define IP6CB(skb)	((struct inet6_skb_parm*)((skb)->cb))
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -63,6 +63,8 @@ struct ipv6_opt_hdr {
 | 
				
			||||||
#define ipv6_destopt_hdr ipv6_opt_hdr
 | 
					#define ipv6_destopt_hdr ipv6_opt_hdr
 | 
				
			||||||
#define ipv6_hopopt_hdr  ipv6_opt_hdr
 | 
					#define ipv6_hopopt_hdr  ipv6_opt_hdr
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Router Alert option values (RFC2711) */
 | 
				
			||||||
 | 
					#define IPV6_OPT_ROUTERALERT_MLD	0x0000	/* MLD(RFC2710) */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
 *	routing header type 0 (used in cmsghdr struct)
 | 
					 *	routing header type 0 (used in cmsghdr struct)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -553,7 +553,8 @@ static bool ipv6_hop_ra(struct sk_buff *skb, int optoff)
 | 
				
			||||||
	const unsigned char *nh = skb_network_header(skb);
 | 
						const unsigned char *nh = skb_network_header(skb);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (nh[optoff + 1] == 2) {
 | 
						if (nh[optoff + 1] == 2) {
 | 
				
			||||||
		IP6CB(skb)->ra = optoff;
 | 
							IP6CB(skb)->flags |= IP6SKB_ROUTERALERT;
 | 
				
			||||||
 | 
							memcpy(&IP6CB(skb)->ra, nh + optoff + 2, sizeof(IP6CB(skb)->ra));
 | 
				
			||||||
		return true;
 | 
							return true;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	LIMIT_NETDEBUG(KERN_DEBUG "ipv6_hop_ra: wrong RA length %d\n",
 | 
						LIMIT_NETDEBUG(KERN_DEBUG "ipv6_hop_ra: wrong RA length %d\n",
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -280,9 +280,8 @@ int ip6_mc_input(struct sk_buff *skb)
 | 
				
			||||||
		struct inet6_skb_parm *opt = IP6CB(skb);
 | 
							struct inet6_skb_parm *opt = IP6CB(skb);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		/* Check for MLD */
 | 
							/* Check for MLD */
 | 
				
			||||||
		if (unlikely(opt->ra)) {
 | 
							if (unlikely(opt->flags & IP6SKB_ROUTERALERT)) {
 | 
				
			||||||
			/* Check if this is a mld message */
 | 
								/* Check if this is a mld message */
 | 
				
			||||||
			u8 *ptr = skb_network_header(skb) + opt->ra;
 | 
					 | 
				
			||||||
			u8 nexthdr = hdr->nexthdr;
 | 
								u8 nexthdr = hdr->nexthdr;
 | 
				
			||||||
			__be16 frag_off;
 | 
								__be16 frag_off;
 | 
				
			||||||
			int offset;
 | 
								int offset;
 | 
				
			||||||
| 
						 | 
					@ -290,7 +289,7 @@ int ip6_mc_input(struct sk_buff *skb)
 | 
				
			||||||
			/* Check if the value of Router Alert
 | 
								/* Check if the value of Router Alert
 | 
				
			||||||
			 * is for MLD (0x0000).
 | 
								 * is for MLD (0x0000).
 | 
				
			||||||
			 */
 | 
								 */
 | 
				
			||||||
			if ((ptr[2] | ptr[3]) == 0) {
 | 
								if (opt->ra == htons(IPV6_OPT_ROUTERALERT_MLD)) {
 | 
				
			||||||
				deliver = false;
 | 
									deliver = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				if (!ipv6_ext_hdr(nexthdr)) {
 | 
									if (!ipv6_ext_hdr(nexthdr)) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue