Skip to content

Commit aef993b

Browse files
ArtisticFantasygregkh
authored andcommitted
ipvs: pass parsed transport offset to state handlers
[ Upstream commit bae7ce7 ] IPVS callers already parse the packet into struct ip_vs_iphdr before updating connection state. For IPv6 this records the real transport-header offset after extension headers in iph.len. Pass this parsed transport offset through ip_vs_set_state() and the protocol state_transition() callback so protocol handlers can use the same packet context as scheduling and NAT handling. This patch only changes the common callback plumbing and adapts the protocol callback signatures; TCP and SCTP start using the value in follow-up patches. Signed-off-by: Yizhou Zhao <zhaoyz24@mails.tsinghua.edu.cn> Acked-by: Julian Anastasov <ja@ssi.bg> Signed-off-by: Florian Westphal <fw@strlen.de> Stable-dep-of: 2500fa3 ("ipvs: use parsed transport offset in TCP state lookup") Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent f03b0a4 commit aef993b

5 files changed

Lines changed: 13 additions & 9 deletions

File tree

include/net/ip_vs.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,8 @@ struct ip_vs_protocol {
455455

456456
void (*state_transition)(struct ip_vs_conn *cp, int direction,
457457
const struct sk_buff *skb,
458-
struct ip_vs_proto_data *pd);
458+
struct ip_vs_proto_data *pd,
459+
unsigned int iph_len);
459460

460461
int (*register_app)(struct netns_ipvs *ipvs, struct ip_vs_app *inc);
461462

net/netfilter/ipvs/ip_vs_core.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -220,10 +220,10 @@ ip_vs_conn_stats(struct ip_vs_conn *cp, struct ip_vs_service *svc)
220220
static inline void
221221
ip_vs_set_state(struct ip_vs_conn *cp, int direction,
222222
const struct sk_buff *skb,
223-
struct ip_vs_proto_data *pd)
223+
struct ip_vs_proto_data *pd, unsigned int iph_len)
224224
{
225225
if (likely(pd->pp->state_transition))
226-
pd->pp->state_transition(cp, direction, skb, pd);
226+
pd->pp->state_transition(cp, direction, skb, pd, iph_len);
227227
}
228228

229229
static inline int
@@ -625,7 +625,7 @@ int ip_vs_leave(struct ip_vs_service *svc, struct sk_buff *skb,
625625
ip_vs_in_stats(cp, skb);
626626

627627
/* set state */
628-
ip_vs_set_state(cp, IP_VS_DIR_INPUT, skb, pd);
628+
ip_vs_set_state(cp, IP_VS_DIR_INPUT, skb, pd, iph->len);
629629

630630
/* transmit the first SYN packet */
631631
ret = cp->packet_xmit(skb, cp, pd->pp, iph);
@@ -1308,7 +1308,7 @@ handle_response(int af, struct sk_buff *skb, struct ip_vs_proto_data *pd,
13081308

13091309
after_nat:
13101310
ip_vs_out_stats(cp, skb);
1311-
ip_vs_set_state(cp, IP_VS_DIR_OUTPUT, skb, pd);
1311+
ip_vs_set_state(cp, IP_VS_DIR_OUTPUT, skb, pd, iph->len);
13121312
skb->ipvs_property = 1;
13131313
if (!(cp->flags & IP_VS_CONN_F_NFCT))
13141314
ip_vs_notrack(skb);
@@ -2060,7 +2060,7 @@ ip_vs_in_hook(void *priv, struct sk_buff *skb, const struct nf_hook_state *state
20602060
IP_VS_DBG_PKT(11, af, pp, skb, iph.off, "Incoming packet");
20612061

20622062
ip_vs_in_stats(cp, skb);
2063-
ip_vs_set_state(cp, IP_VS_DIR_INPUT, skb, pd);
2063+
ip_vs_set_state(cp, IP_VS_DIR_INPUT, skb, pd, iph.len);
20642064
if (cp->packet_xmit)
20652065
ret = cp->packet_xmit(skb, cp, pp, &iph);
20662066
/* do not touch skb anymore */

net/netfilter/ipvs/ip_vs_proto_sctp.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,8 @@ set_sctp_state(struct ip_vs_proto_data *pd, struct ip_vs_conn *cp,
468468

469469
static void
470470
sctp_state_transition(struct ip_vs_conn *cp, int direction,
471-
const struct sk_buff *skb, struct ip_vs_proto_data *pd)
471+
const struct sk_buff *skb, struct ip_vs_proto_data *pd,
472+
unsigned int iph_len)
472473
{
473474
spin_lock_bh(&cp->lock);
474475
set_sctp_state(pd, cp, direction, skb);

net/netfilter/ipvs/ip_vs_proto_tcp.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,8 @@ set_tcp_state(struct ip_vs_proto_data *pd, struct ip_vs_conn *cp,
580580
static void
581581
tcp_state_transition(struct ip_vs_conn *cp, int direction,
582582
const struct sk_buff *skb,
583-
struct ip_vs_proto_data *pd)
583+
struct ip_vs_proto_data *pd,
584+
unsigned int iph_len)
584585
{
585586
struct tcphdr _tcph, *th;
586587

net/netfilter/ipvs/ip_vs_proto_udp.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,8 @@ static const char * udp_state_name(int state)
445445
static void
446446
udp_state_transition(struct ip_vs_conn *cp, int direction,
447447
const struct sk_buff *skb,
448-
struct ip_vs_proto_data *pd)
448+
struct ip_vs_proto_data *pd,
449+
unsigned int iph_len)
449450
{
450451
if (unlikely(!pd)) {
451452
pr_err("UDP no ns data\n");

0 commit comments

Comments
 (0)