Skip to content

Commit c51dfff

Browse files
committed
Merge branch 'gtp-simple-improvements'
Andreas Schultz says: ==================== gtp: simple gtp improvements This is the part of the previous "simple gtp improvements" series that Pablo indicated should go into net-next. The rcu_lock removal is small correctness changes. Passing invalid to user space allows for more standards compliant handling of invalid tunnels. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents 4e8f2fc + 1796a81 commit c51dfff

File tree

1 file changed

+4
-20
lines changed

1 file changed

+4
-20
lines changed

drivers/net/gtp.c

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,6 @@ static int gtp0_udp_encap_recv(struct gtp_dev *gtp, struct sk_buff *skb,
183183
sizeof(struct gtp0_header);
184184
struct gtp0_header *gtp0;
185185
struct pdp_ctx *pctx;
186-
int ret = 0;
187186

188187
if (!pskb_may_pull(skb, hdrlen))
189188
return -1;
@@ -196,26 +195,19 @@ static int gtp0_udp_encap_recv(struct gtp_dev *gtp, struct sk_buff *skb,
196195
if (gtp0->type != GTP_TPDU)
197196
return 1;
198197

199-
rcu_read_lock();
200198
pctx = gtp0_pdp_find(gtp, be64_to_cpu(gtp0->tid));
201199
if (!pctx) {
202200
netdev_dbg(gtp->dev, "No PDP ctx to decap skb=%p\n", skb);
203-
ret = -1;
204-
goto out_rcu;
201+
return 1;
205202
}
206203

207204
if (!gtp_check_src_ms(skb, pctx, hdrlen)) {
208205
netdev_dbg(gtp->dev, "No PDP ctx for this MS\n");
209-
ret = -1;
210-
goto out_rcu;
206+
return 1;
211207
}
212-
rcu_read_unlock();
213208

214209
/* Get rid of the GTP + UDP headers. */
215210
return iptunnel_pull_header(skb, hdrlen, skb->protocol, xnet);
216-
out_rcu:
217-
rcu_read_unlock();
218-
return ret;
219211
}
220212

221213
static int gtp1u_udp_encap_recv(struct gtp_dev *gtp, struct sk_buff *skb,
@@ -225,7 +217,6 @@ static int gtp1u_udp_encap_recv(struct gtp_dev *gtp, struct sk_buff *skb,
225217
sizeof(struct gtp1_header);
226218
struct gtp1_header *gtp1;
227219
struct pdp_ctx *pctx;
228-
int ret = 0;
229220

230221
if (!pskb_may_pull(skb, hdrlen))
231222
return -1;
@@ -253,26 +244,19 @@ static int gtp1u_udp_encap_recv(struct gtp_dev *gtp, struct sk_buff *skb,
253244

254245
gtp1 = (struct gtp1_header *)(skb->data + sizeof(struct udphdr));
255246

256-
rcu_read_lock();
257247
pctx = gtp1_pdp_find(gtp, ntohl(gtp1->tid));
258248
if (!pctx) {
259249
netdev_dbg(gtp->dev, "No PDP ctx to decap skb=%p\n", skb);
260-
ret = -1;
261-
goto out_rcu;
250+
return 1;
262251
}
263252

264253
if (!gtp_check_src_ms(skb, pctx, hdrlen)) {
265254
netdev_dbg(gtp->dev, "No PDP ctx for this MS\n");
266-
ret = -1;
267-
goto out_rcu;
255+
return 1;
268256
}
269-
rcu_read_unlock();
270257

271258
/* Get rid of the GTP + UDP headers. */
272259
return iptunnel_pull_header(skb, hdrlen, skb->protocol, xnet);
273-
out_rcu:
274-
rcu_read_unlock();
275-
return ret;
276260
}
277261

278262
static void gtp_encap_disable(struct gtp_dev *gtp)

0 commit comments

Comments
 (0)