Skip to content

Commit 2dedab6

Browse files
tomparkindavem330
authored andcommitted
l2tp: remove build_header callback in struct l2tp_session
The structure of an L2TP data packet header varies depending on the version of the L2TP protocol being used. struct l2tp_session used to have a build_header callback to abstract this difference away. It's clearer to simply choose the correct function to use when building the data packet (and we save on the function pointer in the session structure). This approach does mean dereferencing the parent tunnel structure in order to determine the tunnel version, but we're doing that in the transmit path in any case. Signed-off-by: Tom Parkin <tparkin@katalix.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 628703f commit 2dedab6

2 files changed

Lines changed: 4 additions & 7 deletions

File tree

‎net/l2tp/l2tp_core.c‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1116,7 +1116,10 @@ int l2tp_xmit_skb(struct l2tp_session *session, struct sk_buff *skb, int hdr_len
11161116
}
11171117

11181118
/* Setup L2TP header */
1119-
session->build_header(session, __skb_push(skb, hdr_len));
1119+
if (tunnel->version == L2TP_HDR_VER_2)
1120+
l2tp_build_l2tpv2_header(session, __skb_push(skb, hdr_len));
1121+
else
1122+
l2tp_build_l2tpv3_header(session, __skb_push(skb, hdr_len));
11201123

11211124
/* Reset skb netfilter state */
11221125
memset(&(IPCB(skb)->opt), 0, sizeof(IPCB(skb)->opt));
@@ -1700,11 +1703,6 @@ struct l2tp_session *l2tp_session_create(int priv_size, struct l2tp_tunnel *tunn
17001703
memcpy(&session->peer_cookie[0], &cfg->peer_cookie[0], cfg->peer_cookie_len);
17011704
}
17021705

1703-
if (tunnel->version == L2TP_HDR_VER_2)
1704-
session->build_header = l2tp_build_l2tpv2_header;
1705-
else
1706-
session->build_header = l2tp_build_l2tpv3_header;
1707-
17081706
l2tp_session_set_header_len(session, tunnel->version);
17091707

17101708
refcount_set(&session->ref_count, 1);

‎net/l2tp/l2tp_core.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ struct l2tp_session {
101101
struct l2tp_stats stats;
102102
struct hlist_node global_hlist; /* global hash list node */
103103

104-
int (*build_header)(struct l2tp_session *session, void *buf);
105104
void (*recv_skb)(struct l2tp_session *session, struct sk_buff *skb, int data_len);
106105
void (*session_close)(struct l2tp_session *session);
107106
void (*show)(struct seq_file *m, void *priv);

0 commit comments

Comments
 (0)