Skip to content

Commit

Permalink
Add net/ modifications
Browse files Browse the repository at this point in the history
Signed-off-by: ShivamKumarJha <[email protected]>
  • Loading branch information
ShivamKumarJha committed Jan 19, 2022
1 parent 381fbff commit 621a9d6
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 3 deletions.
13 changes: 13 additions & 0 deletions net/core/filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -8356,6 +8356,19 @@ static u32 sock_ops_convert_ctx_access(enum bpf_access_type type,
case offsetof(struct bpf_sock_ops, sk):
SOCK_OPS_GET_SK();
break;
// XIAOMI: Add by zholei8 --start
case offsetof(struct bpf_sock_ops, sk_uid):
SOCK_OPS_GET_FIELD(sk_uid, sk_uid, struct sock);
break;

case offsetof(struct bpf_sock_ops, voip_daddr):
SOCK_OPS_GET_FIELD(voip_daddr, sk_daddr, struct sock);
break;

case offsetof(struct bpf_sock_ops, voip_dport):
SOCK_OPS_GET_FIELD(voip_dport, sk_dport, struct sock);
break;
// XIAOMI: Add by zholei8 --end
}
return insn - insn_buf;
}
Expand Down
3 changes: 2 additions & 1 deletion net/ipv4/netfilter/arp_tables.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* Some ARP specific bits are:
*
* Copyright (C) 2002 David S. Miller ([email protected])
* Copyright (C) 2021 XiaoMi, Inc.
* Copyright (C) 2006-2009 Patrick McHardy <[email protected]>
*
*/
Expand Down Expand Up @@ -1406,7 +1407,7 @@ static int compat_get_entries(struct net *net,
xt_compat_lock(NFPROTO_ARP);
t = xt_find_table_lock(net, NFPROTO_ARP, get.name);
if (!IS_ERR(t)) {
const struct xt_table_info *private = t->private;
const struct xt_table_info *private = xt_table_get_private_protected(t);
struct xt_table_info info;

ret = compat_table_info(private, &info);
Expand Down
3 changes: 2 additions & 1 deletion net/ipv4/netfilter/ip_tables.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* Packet matching code.
*
* Copyright (C) 1999 Paul `Rusty' Russell & Michael J. Neuling
* Copyright (C) 2021 XiaoMi, Inc.
* Copyright (C) 2000-2005 Netfilter Core Team <[email protected]>
* Copyright (C) 2006-2010 Patrick McHardy <[email protected]>
*/
Expand Down Expand Up @@ -1616,7 +1617,7 @@ compat_get_entries(struct net *net, struct compat_ipt_get_entries __user *uptr,
xt_compat_lock(AF_INET);
t = xt_find_table_lock(net, AF_INET, get.name);
if (!IS_ERR(t)) {
const struct xt_table_info *private = t->private;
const struct xt_table_info *private = xt_table_get_private_protected(t);
struct xt_table_info info;
ret = compat_table_info(private, &info);
if (!ret && get.size == info.size)
Expand Down
13 changes: 13 additions & 0 deletions net/ipv4/udp.c
Original file line number Diff line number Diff line change
Expand Up @@ -985,6 +985,10 @@ int udp_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
int (*getfrag)(void *, char *, int, int, int, struct sk_buff *);
struct sk_buff *skb;
struct ip_options_data opt_copy;
// xiaomi add by zhoulei8 --start
__be16 tmp_dport;
__be32 tmp_daddr;
// xiaomi add by zhoulei8 --end

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

daddr = usin->sin_addr.s_addr;
dport = usin->sin_port;
// xiaomi add by zhoulei8 --start
tmp_dport = sk->sk_dport;
tmp_daddr = sk->sk_daddr;
sk->sk_dport = dport;
sk->sk_daddr = daddr;
udp_state_bpf(sk);
sk->sk_dport = tmp_dport;
sk->sk_daddr = tmp_daddr;
// xiaomi add by zhoulei8 --end
if (dport == 0)
return -EINVAL;
} else {
Expand Down
3 changes: 2 additions & 1 deletion net/ipv6/netfilter/ip6_tables.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* Packet matching code.
*
* Copyright (C) 1999 Paul `Rusty' Russell & Michael J. Neuling
* Copyright (C) 2021 XiaoMi, Inc.
* Copyright (C) 2000-2005 Netfilter Core Team <[email protected]>
* Copyright (c) 2006-2010 Patrick McHardy <[email protected]>
*/
Expand Down Expand Up @@ -1625,7 +1626,7 @@ compat_get_entries(struct net *net, struct compat_ip6t_get_entries __user *uptr,
xt_compat_lock(AF_INET6);
t = xt_find_table_lock(net, AF_INET6, get.name);
if (!IS_ERR(t)) {
const struct xt_table_info *private = t->private;
const struct xt_table_info *private = xt_table_get_private_protected(t);
struct xt_table_info info;
ret = compat_table_info(private, &info);
if (!ret && get.size == info.size)
Expand Down
14 changes: 14 additions & 0 deletions net/qrtr/qrtr.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (c) 2015, Sony Mobile Communications Inc.
* Copyright (C) 2021 XiaoMi, Inc.
* Copyright (c) 2013, 2018-2019 The Linux Foundation. All rights reserved.
*/
#include <linux/kthread.h>
Expand All @@ -22,8 +23,21 @@
#include "qrtr.h"

#define QRTR_LOG_PAGE_CNT 4

#ifdef CONFIG_DEBUG_POWER_MI
#define QRTR_INFO(ctx, x, ...) \
do { \
ipc_log_string(ctx, x, ##__VA_ARGS__); \
if (qrtr_first_msg) \
{ \
qrtr_first_msg = 0; \
pr_info(x, ##__VA_ARGS__); \
} \
}while(0)
#else
#define QRTR_INFO(ctx, x, ...) \
ipc_log_string(ctx, x, ##__VA_ARGS__)
#endif

#define QRTR_PROTO_VER_1 1
#define QRTR_PROTO_VER_2 3
Expand Down
3 changes: 3 additions & 0 deletions net/qrtr/qrtr.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

#include <linux/types.h>

#ifdef CONFIG_DEBUG_POWER_MI
extern int qrtr_first_msg;
#endif
struct sk_buff;

/* endpoint node id auto assignment */
Expand Down

0 comments on commit 621a9d6

Please sign in to comment.