@@ -436,7 +436,7 @@ ip_vs_schedule(struct ip_vs_service *svc, struct sk_buff *skb,
436436 * with persistence the connection is created on SYN+ACK.
437437 */
438438 if (pptr [0 ] == FTPDATA ) {
439- IP_VS_DBG_PKT (12 , svc -> af , pp , skb , 0 ,
439+ IP_VS_DBG_PKT (12 , svc -> af , pp , skb , iph -> off ,
440440 "Not scheduling FTPDATA" );
441441 return NULL ;
442442 }
@@ -446,7 +446,7 @@ ip_vs_schedule(struct ip_vs_service *svc, struct sk_buff *skb,
446446 */
447447 if ((!skb -> dev || skb -> dev -> flags & IFF_LOOPBACK ) &&
448448 (cp = pp -> conn_in_get (svc -> af , skb , iph , 1 ))) {
449- IP_VS_DBG_PKT (12 , svc -> af , pp , skb , 0 ,
449+ IP_VS_DBG_PKT (12 , svc -> af , pp , skb , iph -> off ,
450450 "Not scheduling reply for existing connection" );
451451 __ip_vs_conn_put (cp );
452452 return NULL ;
@@ -934,8 +934,8 @@ static int ip_vs_out_icmp(struct sk_buff *skb, int *related,
934934 IP_VS_DBG_PKT (11 , AF_INET , pp , skb , offset ,
935935 "Checking outgoing ICMP for" );
936936
937- ip_vs_fill_ip4hdr ( cih , & ciph );
938- ciph . len += offset ;
937+ ip_vs_fill_iph_skb_off ( AF_INET , skb , offset , & ciph );
938+
939939 /* The embedded headers contain source and dest in reverse order */
940940 cp = pp -> conn_out_get (AF_INET , skb , & ciph , 1 );
941941 if (!cp )
@@ -951,12 +951,11 @@ static int ip_vs_out_icmp_v6(struct sk_buff *skb, int *related,
951951 unsigned int hooknum , struct ip_vs_iphdr * ipvsh )
952952{
953953 struct icmp6hdr _icmph , * ic ;
954- struct ipv6hdr _ip6h , * ip6h ; /* The ip header contained within ICMP */
955954 struct ip_vs_iphdr ciph = {.flags = 0 , .fragoffs = 0 };/*Contained IP */
956955 struct ip_vs_conn * cp ;
957956 struct ip_vs_protocol * pp ;
958957 union nf_inet_addr snet ;
959- unsigned int writable ;
958+ unsigned int offset ;
960959
961960 * related = 1 ;
962961 ic = frag_safe_skb_hp (skb , ipvsh -> len , sizeof (_icmph ), & _icmph , ipvsh );
@@ -984,17 +983,9 @@ static int ip_vs_out_icmp_v6(struct sk_buff *skb, int *related,
984983 ic -> icmp6_type , ntohs (icmpv6_id (ic )),
985984 & ipvsh -> saddr , & ipvsh -> daddr );
986985
987- /* Now find the contained IP header */
988- ciph .len = ipvsh -> len + sizeof (_icmph );
989- ip6h = skb_header_pointer (skb , ciph .len , sizeof (_ip6h ), & _ip6h );
990- if (ip6h == NULL )
986+ if (!ip_vs_fill_iph_skb_off (AF_INET6 , skb , ipvsh -> len + sizeof (_icmph ),
987+ & ciph ))
991988 return NF_ACCEPT ; /* The packet looks wrong, ignore */
992- ciph .saddr .in6 = ip6h -> saddr ; /* conn_out_get() handles reverse order */
993- ciph .daddr .in6 = ip6h -> daddr ;
994- /* skip possible IPv6 exthdrs of contained IPv6 packet */
995- ciph .protocol = ipv6_find_hdr (skb , & ciph .len , -1 , & ciph .fragoffs , NULL );
996- if (ciph .protocol < 0 )
997- return NF_ACCEPT ; /* Contained IPv6 hdr looks wrong, ignore */
998989
999990 pp = ip_vs_proto_get (ciph .protocol );
1000991 if (!pp )
@@ -1006,9 +997,9 @@ static int ip_vs_out_icmp_v6(struct sk_buff *skb, int *related,
1006997 return NF_ACCEPT ;
1007998
1008999 snet .in6 = ciph .saddr .in6 ;
1009- writable = ciph .len ;
1000+ offset = ciph .len ;
10101001 return handle_response_icmp (AF_INET6 , skb , & snet , ciph .protocol , cp ,
1011- pp , writable , sizeof (struct ipv6hdr ),
1002+ pp , offset , sizeof (struct ipv6hdr ),
10121003 hooknum );
10131004}
10141005#endif
@@ -1093,7 +1084,7 @@ handle_response(int af, struct sk_buff *skb, struct ip_vs_proto_data *pd,
10931084{
10941085 struct ip_vs_protocol * pp = pd -> pp ;
10951086
1096- IP_VS_DBG_PKT (11 , af , pp , skb , 0 , "Outgoing packet" );
1087+ IP_VS_DBG_PKT (11 , af , pp , skb , iph -> off , "Outgoing packet" );
10971088
10981089 if (!skb_make_writable (skb , iph -> len ))
10991090 goto drop ;
@@ -1130,7 +1121,7 @@ handle_response(int af, struct sk_buff *skb, struct ip_vs_proto_data *pd,
11301121 if (ip_vs_route_me_harder (af , skb , hooknum ))
11311122 goto drop ;
11321123
1133- IP_VS_DBG_PKT (10 , af , pp , skb , 0 , "After SNAT" );
1124+ IP_VS_DBG_PKT (10 , af , pp , skb , iph -> off , "After SNAT" );
11341125
11351126 ip_vs_out_stats (cp , skb );
11361127 ip_vs_set_state (cp , IP_VS_DIR_OUTPUT , skb , pd );
@@ -1221,7 +1212,7 @@ ip_vs_out(unsigned int hooknum, struct sk_buff *skb, int af)
12211212 ip_vs_defrag_user (hooknum )))
12221213 return NF_STOLEN ;
12231214
1224- ip_vs_fill_ip4hdr ( skb_network_header ( skb ) , & iph );
1215+ ip_vs_fill_iph_skb ( AF_INET , skb , & iph );
12251216 }
12261217
12271218 /*
@@ -1272,7 +1263,7 @@ ip_vs_out(unsigned int hooknum, struct sk_buff *skb, int af)
12721263 }
12731264 }
12741265 }
1275- IP_VS_DBG_PKT (12 , af , pp , skb , 0 ,
1266+ IP_VS_DBG_PKT (12 , af , pp , skb , iph . off ,
12761267 "ip_vs_out: packet continues traversal as normal" );
12771268 return NF_ACCEPT ;
12781269}
@@ -1416,9 +1407,9 @@ ip_vs_in_icmp(struct sk_buff *skb, int *related, unsigned int hooknum)
14161407 "Checking incoming ICMP for" );
14171408
14181409 offset2 = offset ;
1419- ip_vs_fill_ip4hdr (cih , & ciph );
1420- ciph .len += offset ;
1410+ ip_vs_fill_iph_skb_off (AF_INET , skb , offset , & ciph );
14211411 offset = ciph .len ;
1412+
14221413 /* The embedded headers contain source and dest in reverse order.
14231414 * For IPIP this is error for request, not for reply.
14241415 */
@@ -1511,13 +1502,12 @@ static int ip_vs_in_icmp_v6(struct sk_buff *skb, int *related,
15111502 unsigned int hooknum , struct ip_vs_iphdr * iph )
15121503{
15131504 struct net * net = NULL ;
1514- struct ipv6hdr _ip6h , * ip6h ;
15151505 struct icmp6hdr _icmph , * ic ;
15161506 struct ip_vs_iphdr ciph = {.flags = 0 , .fragoffs = 0 };/*Contained IP */
15171507 struct ip_vs_conn * cp ;
15181508 struct ip_vs_protocol * pp ;
15191509 struct ip_vs_proto_data * pd ;
1520- unsigned int offs_ciph , writable , verdict ;
1510+ unsigned int offset , verdict ;
15211511
15221512 * related = 1 ;
15231513
@@ -1546,18 +1536,9 @@ static int ip_vs_in_icmp_v6(struct sk_buff *skb, int *related,
15461536 ic -> icmp6_type , ntohs (icmpv6_id (ic )),
15471537 & iph -> saddr , & iph -> daddr );
15481538
1549- /* Now find the contained IP header */
1550- ciph .len = iph -> len + sizeof (_icmph );
1551- offs_ciph = ciph .len ; /* Save ip header offset */
1552- ip6h = skb_header_pointer (skb , ciph .len , sizeof (_ip6h ), & _ip6h );
1553- if (ip6h == NULL )
1554- return NF_ACCEPT ; /* The packet looks wrong, ignore */
1555- ciph .saddr .in6 = ip6h -> saddr ; /* conn_in_get() handles reverse order */
1556- ciph .daddr .in6 = ip6h -> daddr ;
1557- /* skip possible IPv6 exthdrs of contained IPv6 packet */
1558- ciph .protocol = ipv6_find_hdr (skb , & ciph .len , -1 , & ciph .fragoffs , NULL );
1559- if (ciph .protocol < 0 )
1560- return NF_ACCEPT ; /* Contained IPv6 hdr looks wrong, ignore */
1539+ offset = iph -> len + sizeof (_icmph );
1540+ if (!ip_vs_fill_iph_skb_off (AF_INET6 , skb , offset , & ciph ))
1541+ return NF_ACCEPT ;
15611542
15621543 net = skb_net (skb );
15631544 pd = ip_vs_proto_data_get (net , ciph .protocol );
@@ -1569,7 +1550,7 @@ static int ip_vs_in_icmp_v6(struct sk_buff *skb, int *related,
15691550 if (ciph .fragoffs )
15701551 return NF_ACCEPT ;
15711552
1572- IP_VS_DBG_PKT (11 , AF_INET6 , pp , skb , offs_ciph ,
1553+ IP_VS_DBG_PKT (11 , AF_INET6 , pp , skb , offset ,
15731554 "Checking incoming ICMPv6 for" );
15741555
15751556 /* The embedded headers contain source and dest in reverse order
@@ -1591,12 +1572,12 @@ static int ip_vs_in_icmp_v6(struct sk_buff *skb, int *related,
15911572 ip_vs_in_stats (cp , skb );
15921573
15931574 /* Need to mangle contained IPv6 header in ICMPv6 packet */
1594- writable = ciph .len ;
1575+ offset = ciph .len ;
15951576 if (IPPROTO_TCP == ciph .protocol || IPPROTO_UDP == ciph .protocol ||
15961577 IPPROTO_SCTP == ciph .protocol )
1597- writable += 2 * sizeof (__u16 ); /* Also mangle ports */
1578+ offset += 2 * sizeof (__u16 ); /* Also mangle ports */
15981579
1599- verdict = ip_vs_icmp_xmit_v6 (skb , cp , pp , writable , hooknum , & ciph );
1580+ verdict = ip_vs_icmp_xmit_v6 (skb , cp , pp , offset , hooknum , & ciph );
16001581
16011582 __ip_vs_conn_put (cp );
16021583
@@ -1720,12 +1701,13 @@ ip_vs_in(unsigned int hooknum, struct sk_buff *skb, int af)
17201701 * is missing module nf_defrag_ipv6
17211702 */
17221703 IP_VS_DBG_RL ("Unhandled frag, load nf_defrag_ipv6\n" );
1723- IP_VS_DBG_PKT (7 , af , pp , skb , 0 , "unhandled fragment" );
1704+ IP_VS_DBG_PKT (7 , af , pp , skb , iph .off ,
1705+ "unhandled fragment" );
17241706 }
17251707 return NF_ACCEPT ;
17261708 }
17271709
1728- IP_VS_DBG_PKT (11 , af , pp , skb , 0 , "Incoming packet" );
1710+ IP_VS_DBG_PKT (11 , af , pp , skb , iph . off , "Incoming packet" );
17291711 /* Check the server status */
17301712 if (cp -> dest && !(cp -> dest -> flags & IP_VS_DEST_F_AVAILABLE )) {
17311713 /* the destination server is not available */
0 commit comments