Skip to content

Commit 621a9d6

Browse files
Add net/ modifications
Signed-off-by: ShivamKumarJha <[email protected]>
1 parent 381fbff commit 621a9d6

File tree

7 files changed

+49
-3
lines changed

7 files changed

+49
-3
lines changed

net/core/filter.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8356,6 +8356,19 @@ static u32 sock_ops_convert_ctx_access(enum bpf_access_type type,
83568356
case offsetof(struct bpf_sock_ops, sk):
83578357
SOCK_OPS_GET_SK();
83588358
break;
8359+
// XIAOMI: Add by zholei8 --start
8360+
case offsetof(struct bpf_sock_ops, sk_uid):
8361+
SOCK_OPS_GET_FIELD(sk_uid, sk_uid, struct sock);
8362+
break;
8363+
8364+
case offsetof(struct bpf_sock_ops, voip_daddr):
8365+
SOCK_OPS_GET_FIELD(voip_daddr, sk_daddr, struct sock);
8366+
break;
8367+
8368+
case offsetof(struct bpf_sock_ops, voip_dport):
8369+
SOCK_OPS_GET_FIELD(voip_dport, sk_dport, struct sock);
8370+
break;
8371+
// XIAOMI: Add by zholei8 --end
83598372
}
83608373
return insn - insn_buf;
83618374
}

net/ipv4/netfilter/arp_tables.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* Some ARP specific bits are:
88
*
99
* Copyright (C) 2002 David S. Miller ([email protected])
10+
* Copyright (C) 2021 XiaoMi, Inc.
1011
* Copyright (C) 2006-2009 Patrick McHardy <[email protected]>
1112
*
1213
*/
@@ -1406,7 +1407,7 @@ static int compat_get_entries(struct net *net,
14061407
xt_compat_lock(NFPROTO_ARP);
14071408
t = xt_find_table_lock(net, NFPROTO_ARP, get.name);
14081409
if (!IS_ERR(t)) {
1409-
const struct xt_table_info *private = t->private;
1410+
const struct xt_table_info *private = xt_table_get_private_protected(t);
14101411
struct xt_table_info info;
14111412

14121413
ret = compat_table_info(private, &info);

net/ipv4/netfilter/ip_tables.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* Packet matching code.
44
*
55
* Copyright (C) 1999 Paul `Rusty' Russell & Michael J. Neuling
6+
* Copyright (C) 2021 XiaoMi, Inc.
67
* Copyright (C) 2000-2005 Netfilter Core Team <[email protected]>
78
* Copyright (C) 2006-2010 Patrick McHardy <[email protected]>
89
*/
@@ -1616,7 +1617,7 @@ compat_get_entries(struct net *net, struct compat_ipt_get_entries __user *uptr,
16161617
xt_compat_lock(AF_INET);
16171618
t = xt_find_table_lock(net, AF_INET, get.name);
16181619
if (!IS_ERR(t)) {
1619-
const struct xt_table_info *private = t->private;
1620+
const struct xt_table_info *private = xt_table_get_private_protected(t);
16201621
struct xt_table_info info;
16211622
ret = compat_table_info(private, &info);
16221623
if (!ret && get.size == info.size)

net/ipv4/udp.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -985,6 +985,10 @@ int udp_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
985985
int (*getfrag)(void *, char *, int, int, int, struct sk_buff *);
986986
struct sk_buff *skb;
987987
struct ip_options_data opt_copy;
988+
// xiaomi add by zhoulei8 --start
989+
__be16 tmp_dport;
990+
__be32 tmp_daddr;
991+
// xiaomi add by zhoulei8 --end
988992

989993
if (len > 0xFFFF)
990994
return -EMSGSIZE;
@@ -1029,6 +1033,15 @@ int udp_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
10291033

10301034
daddr = usin->sin_addr.s_addr;
10311035
dport = usin->sin_port;
1036+
// xiaomi add by zhoulei8 --start
1037+
tmp_dport = sk->sk_dport;
1038+
tmp_daddr = sk->sk_daddr;
1039+
sk->sk_dport = dport;
1040+
sk->sk_daddr = daddr;
1041+
udp_state_bpf(sk);
1042+
sk->sk_dport = tmp_dport;
1043+
sk->sk_daddr = tmp_daddr;
1044+
// xiaomi add by zhoulei8 --end
10321045
if (dport == 0)
10331046
return -EINVAL;
10341047
} else {

net/ipv6/netfilter/ip6_tables.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* Packet matching code.
44
*
55
* Copyright (C) 1999 Paul `Rusty' Russell & Michael J. Neuling
6+
* Copyright (C) 2021 XiaoMi, Inc.
67
* Copyright (C) 2000-2005 Netfilter Core Team <[email protected]>
78
* Copyright (c) 2006-2010 Patrick McHardy <[email protected]>
89
*/
@@ -1625,7 +1626,7 @@ compat_get_entries(struct net *net, struct compat_ip6t_get_entries __user *uptr,
16251626
xt_compat_lock(AF_INET6);
16261627
t = xt_find_table_lock(net, AF_INET6, get.name);
16271628
if (!IS_ERR(t)) {
1628-
const struct xt_table_info *private = t->private;
1629+
const struct xt_table_info *private = xt_table_get_private_protected(t);
16291630
struct xt_table_info info;
16301631
ret = compat_table_info(private, &info);
16311632
if (!ret && get.size == info.size)

net/qrtr/qrtr.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// SPDX-License-Identifier: GPL-2.0-only
22
/*
33
* Copyright (c) 2015, Sony Mobile Communications Inc.
4+
* Copyright (C) 2021 XiaoMi, Inc.
45
* Copyright (c) 2013, 2018-2019 The Linux Foundation. All rights reserved.
56
*/
67
#include <linux/kthread.h>
@@ -22,8 +23,21 @@
2223
#include "qrtr.h"
2324

2425
#define QRTR_LOG_PAGE_CNT 4
26+
27+
#ifdef CONFIG_DEBUG_POWER_MI
28+
#define QRTR_INFO(ctx, x, ...) \
29+
do { \
30+
ipc_log_string(ctx, x, ##__VA_ARGS__); \
31+
if (qrtr_first_msg) \
32+
{ \
33+
qrtr_first_msg = 0; \
34+
pr_info(x, ##__VA_ARGS__); \
35+
} \
36+
}while(0)
37+
#else
2538
#define QRTR_INFO(ctx, x, ...) \
2639
ipc_log_string(ctx, x, ##__VA_ARGS__)
40+
#endif
2741

2842
#define QRTR_PROTO_VER_1 1
2943
#define QRTR_PROTO_VER_2 3

net/qrtr/qrtr.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
#include <linux/types.h>
66

7+
#ifdef CONFIG_DEBUG_POWER_MI
8+
extern int qrtr_first_msg;
9+
#endif
710
struct sk_buff;
811

912
/* endpoint node id auto assignment */

0 commit comments

Comments
 (0)