Commit 97d13703 authored by 程佳奇's avatar 程佳奇
Browse files

network_mgmt: Add ip_notify timer print.

driver inclusion
category: cleanup
bugzilla: https://gitee.com/openeuler/kernel/issues/IAQT7G


CVE: NA

----------------------------------------------------------------------

1.Added an echo print to remind users of the current period time
for modifying the ip_notify timer.
2.When packets are counted, increase judgment for
'NET_XMIT_CN'/'-ENOMEM'/'-ENETDOWN' of return values.

Signed-off-by: default avatarJiaqi Cheng <chengjiaqi3@huawei.com>
parent edbc9827
Loading
Loading
Loading
Loading
+48 −3
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@

#include <linux/timer.h>
#include <linux/types.h>
#include <linux/version.h>

#include "ubl.h"
#include "network_mgmt.h"
@@ -473,6 +474,9 @@ static void ub_update_tx_stats(int ptype, struct net_device *ndev, int rc)
		break;
	case NET_XMIT_DROP:
	case NETDEV_TX_BUSY:
	case NET_XMIT_CN:
	case -ENOMEM:
	case -ENETDOWN:
		if (ptype == UB_PROTO_IPV4)
			atomic64_inc(&nm_dev->sys_ctx.ip_notify_ctx.stats.bad_ipv4_notify_tx_cnt);
		else
@@ -611,6 +615,48 @@ static int ip_notify_enable;
static int ip_notify_tx_hold = 1;
static int ip_notify_tx_hold_max = (INT_MAX / IP_NOTIFY_TIMEOUT_MS);

static int ip_notify_enable_change(struct ctl_table *table, int write,
				   void *buffer, size_t *lenp, loff_t *ppos)
{
	u32 period_notify_time;
	int ret;

	ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
	if (ret)
		return ret;

	if (write && ip_notify_enable) {
		period_notify_time = ip_notify_tx_hold * IP_NOTIFY_TIMEOUT_S;
		pr_warn("period notify timer is %us.\n", period_notify_time);
	}

	return 0;
}

static int ip_notify_tx_hold_change(struct ctl_table *table, int write,
				    void *buffer, size_t *lenp, loff_t *ppos)
{
	u32 period_notify_time;
	int ret;

	ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
	if (ret)
		return ret;

	if (!write)
		return 0;

	if (ip_notify_enable) {
		period_notify_time = ip_notify_tx_hold * IP_NOTIFY_TIMEOUT_S;
		pr_warn("setting period notify timer to %us.\n",
			period_notify_time);
	} else {
		pr_warn("ip notify timer disable.\n");
	}

	return 0;
}

static struct ctl_table_header *sysctl_header;
static struct ctl_table ip_notify_sysctl[] = {
	{
@@ -618,7 +664,7 @@ static struct ctl_table ip_notify_sysctl[] = {
		.data		= &ip_notify_enable,
		.maxlen		= sizeof(ip_notify_enable),
		.mode		= 0644,
		.proc_handler	= proc_dointvec_minmax,
		.proc_handler	= ip_notify_enable_change,
		.extra1		= SYSCTL_ZERO,
		.extra2		= SYSCTL_ONE,
	},
@@ -627,7 +673,7 @@ static struct ctl_table ip_notify_sysctl[] = {
		.data		= &ip_notify_tx_hold,
		.maxlen		= sizeof(ip_notify_tx_hold),
		.mode		= 0644,
		.proc_handler	= proc_dointvec_minmax,
		.proc_handler	= ip_notify_tx_hold_change,
		.extra1		= SYSCTL_ONE,
		.extra2		= &ip_notify_tx_hold_max,
	},
@@ -646,7 +692,6 @@ static int ub_ip_notify_sysctl_init(void)
					      ip_notify_sysctl);
	if (sysctl_header)
		return 0;

	pr_warn("ip_notify sysctl init failed!\n");
	return 1;
}
+1 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@
#define IPV6_ADDR_LEN 16
#define VER_SHIFT_4 4u
#define IP_NOTIFY_TIMEOUT_MS 30000
#define IP_NOTIFY_TIMEOUT_S 30

/* IP Protocol type */
enum { UB_PROTO_IPV4 = 1, UB_PROTO_IPV6 };