Skip to content

Commit

Permalink
l2tp: remove header length param from l2tp_xmit_skb
Browse files Browse the repository at this point in the history
All callers pass the session structure's hdr_len field as the header
length parameter to l2tp_xmit_skb.

Since we're passing a pointer to the session structure to l2tp_xmit_skb
anyway, there's not much point breaking the header length out as a
separate argument.

Signed-off-by: Tom Parkin <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
tomparkin authored and davem330 committed Sep 3, 2020
1 parent ffd923f commit efe0527
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
10 changes: 5 additions & 5 deletions net/l2tp/l2tp_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1017,7 +1017,7 @@ static void l2tp_xmit_core(struct l2tp_session *session, struct sk_buff *skb,
/* If caller requires the skb to have a ppp header, the header must be
* inserted in the skb data before calling this function.
*/
int l2tp_xmit_skb(struct l2tp_session *session, struct sk_buff *skb, int hdr_len)
int l2tp_xmit_skb(struct l2tp_session *session, struct sk_buff *skb)
{
int data_len = skb->len;
struct l2tp_tunnel *tunnel = session->tunnel;
Expand All @@ -1035,17 +1035,17 @@ int l2tp_xmit_skb(struct l2tp_session *session, struct sk_buff *skb, int hdr_len
* make room. Adjust truesize.
*/
headroom = NET_SKB_PAD + sizeof(struct iphdr) +
uhlen + hdr_len;
uhlen + session->hdr_len;
if (skb_cow_head(skb, headroom)) {
kfree_skb(skb);
return NET_XMIT_DROP;
}

/* Setup L2TP header */
if (tunnel->version == L2TP_HDR_VER_2)
l2tp_build_l2tpv2_header(session, __skb_push(skb, hdr_len));
l2tp_build_l2tpv2_header(session, __skb_push(skb, session->hdr_len));
else
l2tp_build_l2tpv3_header(session, __skb_push(skb, hdr_len));
l2tp_build_l2tpv3_header(session, __skb_push(skb, session->hdr_len));

/* Reset skb netfilter state */
memset(&(IPCB(skb)->opt), 0, sizeof(IPCB(skb)->opt));
Expand Down Expand Up @@ -1079,7 +1079,7 @@ int l2tp_xmit_skb(struct l2tp_session *session, struct sk_buff *skb, int hdr_len
uh = udp_hdr(skb);
uh->source = inet->inet_sport;
uh->dest = inet->inet_dport;
udp_len = uhlen + hdr_len + data_len;
udp_len = uhlen + session->hdr_len + data_len;
uh->len = htons(udp_len);

/* Calculate UDP checksum if configured to do so */
Expand Down
3 changes: 1 addition & 2 deletions net/l2tp/l2tp_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,7 @@ int l2tp_udp_encap_recv(struct sock *sk, struct sk_buff *skb);

/* Transmit path helpers for sending packets over the tunnel socket. */
void l2tp_session_set_header_len(struct l2tp_session *session, int version);
int l2tp_xmit_skb(struct l2tp_session *session, struct sk_buff *skb,
int hdr_len);
int l2tp_xmit_skb(struct l2tp_session *session, struct sk_buff *skb);

/* Pseudowire management.
* Pseudowires should register with l2tp core on module init, and unregister
Expand Down
2 changes: 1 addition & 1 deletion net/l2tp/l2tp_eth.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ static netdev_tx_t l2tp_eth_dev_xmit(struct sk_buff *skb, struct net_device *dev
struct l2tp_eth *priv = netdev_priv(dev);
struct l2tp_session *session = priv->session;
unsigned int len = skb->len;
int ret = l2tp_xmit_skb(session, skb, session->hdr_len);
int ret = l2tp_xmit_skb(session, skb);

if (likely(ret == NET_XMIT_SUCCESS)) {
atomic_long_add(len, &priv->tx_bytes);
Expand Down
4 changes: 2 additions & 2 deletions net/l2tp/l2tp_ppp.c
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ static int pppol2tp_sendmsg(struct socket *sock, struct msghdr *m,
}

local_bh_disable();
l2tp_xmit_skb(session, skb, session->hdr_len);
l2tp_xmit_skb(session, skb);
local_bh_enable();

sock_put(sk);
Expand Down Expand Up @@ -375,7 +375,7 @@ static int pppol2tp_xmit(struct ppp_channel *chan, struct sk_buff *skb)
skb->data[1] = PPP_UI;

local_bh_disable();
l2tp_xmit_skb(session, skb, session->hdr_len);
l2tp_xmit_skb(session, skb);
local_bh_enable();

sock_put(sk);
Expand Down

0 comments on commit efe0527

Please sign in to comment.