kernel: Update kernel 4.19 to version 4.19.131

Fixes:
- CVE-2020-10757

The "mtd: rawnand: Pass a nand_chip object to nand_release()" commit was
backported which needed some adaptations to other code.

Run tested: ath79
Build tested: ath79

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
This commit is contained in:
Hauke Mehrtens 2020-07-04 01:34:26 +02:00 committed by AmadeusGhost
parent 0287f7cc12
commit 55e55bffc0
28 changed files with 186 additions and 261 deletions

View File

@ -8,11 +8,11 @@ endif
LINUX_VERSION-4.9 = .229
LINUX_VERSION-4.14 = .187
LINUX_VERSION-4.19 = .130
LINUX_VERSION-4.19 = .131
LINUX_KERNEL_HASH-4.9.229 = 3256c2835fd95a1a739603e78b02d363eac2ce73a39fa19b13b32da4fc370fdc
LINUX_KERNEL_HASH-4.14.187 = 5b223475eaeea196aa7e127d3f253bca5c35d8afdc72ca75230ce1ecdd1454bd
LINUX_KERNEL_HASH-4.19.130 = a692c0e61dc885b4d6e66ae7bf202dadf7d5538fbf92766ce7cf8e227fd4f00f
LINUX_KERNEL_HASH-4.19.131 = 19dfb9f6cc4ba30104b65dcce7d78240a4ae188cb366747d5f8eae35e98964ba
remove_uri_prefix=$(subst git://,,$(subst http://,,$(subst https://,,$(1))))
sanitize_uri=$(call qstrip,$(subst @,_,$(subst :,_,$(subst .,_,$(subst -,_,$(subst /,_,$(1)))))))

View File

@ -631,11 +631,19 @@ static void ar934x_nfc_read_status(struct ar934x_nfc *nfc)
nfc->buf[0] = status;
}
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 20, 0)
static void ar934x_nfc_cmdfunc(struct mtd_info *mtd, unsigned int command,
int column, int page_addr)
{
struct ar934x_nfc *nfc = mtd_to_ar934x_nfc(mtd);
struct nand_chip *nand = &nfc->nand_chip;
#else
static void ar934x_nfc_cmdfunc(struct nand_chip *nand, unsigned int command,
int column, int page_addr)
{
struct mtd_info *mtd = nand_to_mtd(nand);
struct ar934x_nfc *nfc = nand->priv;
#endif
nfc->read_id = false;
if (command != NAND_CMD_PAGEPROG)
@ -740,16 +748,28 @@ static void ar934x_nfc_cmdfunc(struct mtd_info *mtd, unsigned int command,
}
}
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 20, 0)
static int ar934x_nfc_dev_ready(struct mtd_info *mtd)
{
struct ar934x_nfc *nfc = mtd_to_ar934x_nfc(mtd);
#else
static int ar934x_nfc_dev_ready(struct nand_chip *chip)
{
struct ar934x_nfc *nfc = chip->priv;
#endif
return __ar934x_nfc_dev_ready(nfc);
}
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 20, 0)
static u8 ar934x_nfc_read_byte(struct mtd_info *mtd)
{
struct ar934x_nfc *nfc = mtd_to_ar934x_nfc(mtd);
#else
static u8 ar934x_nfc_read_byte(struct nand_chip *chip)
{
struct ar934x_nfc *nfc = chip->priv;
#endif
u8 data;
WARN_ON(nfc->buf_index >= nfc->buf_size);
@ -764,9 +784,15 @@ static u8 ar934x_nfc_read_byte(struct mtd_info *mtd)
return data;
}
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 20, 0)
static void ar934x_nfc_write_buf(struct mtd_info *mtd, const u8 *buf, int len)
{
struct ar934x_nfc *nfc = mtd_to_ar934x_nfc(mtd);
#else
static void ar934x_nfc_write_buf(struct nand_chip *chip, const u8 *buf, int len)
{
struct ar934x_nfc *nfc = chip->priv;
#endif
int i;
WARN_ON(nfc->buf_index + len > nfc->buf_size);
@ -784,9 +810,15 @@ static void ar934x_nfc_write_buf(struct mtd_info *mtd, const u8 *buf, int len)
}
}
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 20, 0)
static void ar934x_nfc_read_buf(struct mtd_info *mtd, u8 *buf, int len)
{
struct ar934x_nfc *nfc = mtd_to_ar934x_nfc(mtd);
#else
static void ar934x_nfc_read_buf(struct nand_chip *chip, u8 *buf, int len)
{
struct ar934x_nfc *nfc = chip->priv;
#endif
int buf_index;
int i;
@ -821,10 +853,18 @@ static inline void ar934x_nfc_disable_hwecc(struct ar934x_nfc *nfc)
nfc->ctrl_reg |= AR934X_NFC_CTRL_CUSTOM_SIZE_EN;
}
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 20, 0)
static int ar934x_nfc_read_oob(struct mtd_info *mtd, struct nand_chip *chip,
int page)
{
struct ar934x_nfc *nfc = mtd_to_ar934x_nfc(mtd);
#else
static int ar934x_nfc_read_oob(struct nand_chip *chip,
int page)
{
struct ar934x_nfc *nfc = chip->priv;
struct mtd_info *mtd = ar934x_nfc_to_mtd(nfc);
#endif
int err;
nfc_dbg(nfc, "read_oob: page:%d\n", page);
@ -839,11 +879,18 @@ static int ar934x_nfc_read_oob(struct mtd_info *mtd, struct nand_chip *chip,
return 0;
}
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 20, 0)
static int ar934x_nfc_write_oob(struct mtd_info *mtd, struct nand_chip *chip,
int page)
{
struct ar934x_nfc *nfc = mtd_to_ar934x_nfc(mtd);
#else
static int ar934x_nfc_write_oob(struct nand_chip *chip,
int page)
{
struct ar934x_nfc *nfc = chip->priv;
struct mtd_info *mtd = ar934x_nfc_to_mtd(nfc);
#endif
nfc_dbg(nfc, "write_oob: page:%d\n", page);
memcpy(nfc->buf, chip->oob_poi, mtd->oobsize);
@ -852,11 +899,20 @@ static int ar934x_nfc_write_oob(struct mtd_info *mtd, struct nand_chip *chip,
page, mtd->oobsize);
}
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 20, 0)
static int ar934x_nfc_read_page_raw(struct mtd_info *mtd,
struct nand_chip *chip, u8 *buf,
int oob_required, int page)
{
struct ar934x_nfc *nfc = mtd_to_ar934x_nfc(mtd);
#else
static int ar934x_nfc_read_page_raw(
struct nand_chip *chip, u8 *buf,
int oob_required, int page)
{
struct ar934x_nfc *nfc = chip->priv;
struct mtd_info *mtd = ar934x_nfc_to_mtd(nfc);
#endif
int len;
int err;
@ -878,10 +934,18 @@ static int ar934x_nfc_read_page_raw(struct mtd_info *mtd,
return 0;
}
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 20, 0)
static int ar934x_nfc_read_page(struct mtd_info *mtd, struct nand_chip *chip,
u8 *buf, int oob_required, int page)
{
struct ar934x_nfc *nfc = mtd_to_ar934x_nfc(mtd);
#else
static int ar934x_nfc_read_page(struct nand_chip *chip,
u8 *buf, int oob_required, int page)
{
struct ar934x_nfc *nfc = chip->priv;
struct mtd_info *mtd = ar934x_nfc_to_mtd(nfc);
#endif
u32 ecc_ctrl;
int max_bitflips = 0;
bool ecc_failed;
@ -950,11 +1014,20 @@ static int ar934x_nfc_read_page(struct mtd_info *mtd, struct nand_chip *chip,
return max_bitflips;
}
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 20, 0)
static int ar934x_nfc_write_page_raw(struct mtd_info *mtd,
struct nand_chip *chip, const u8 *buf,
int oob_required, int page)
{
struct ar934x_nfc *nfc = mtd_to_ar934x_nfc(mtd);
#else
static int ar934x_nfc_write_page_raw(
struct nand_chip *chip, const u8 *buf,
int oob_required, int page)
{
struct ar934x_nfc *nfc = chip->priv;
struct mtd_info *mtd = ar934x_nfc_to_mtd(nfc);
#endif
int len;
nfc_dbg(nfc, "write_page_raw: page:%d oob:%d\n", page, oob_required);
@ -970,10 +1043,18 @@ static int ar934x_nfc_write_page_raw(struct mtd_info *mtd,
return ar934x_nfc_send_write(nfc, NAND_CMD_PAGEPROG, 0, page, len);
}
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 20, 0)
static int ar934x_nfc_write_page(struct mtd_info *mtd, struct nand_chip *chip,
const u8 *buf, int oob_required, int page)
{
struct ar934x_nfc *nfc = mtd_to_ar934x_nfc(mtd);
#else
static int ar934x_nfc_write_page(struct nand_chip *chip,
const u8 *buf, int oob_required, int page)
{
struct ar934x_nfc *nfc = chip->priv;
struct mtd_info *mtd = ar934x_nfc_to_mtd(nfc);
#endif
int err;
nfc_dbg(nfc, "write_page: page:%d oob:%d\n", page, oob_required);
@ -981,7 +1062,11 @@ static int ar934x_nfc_write_page(struct mtd_info *mtd, struct nand_chip *chip,
/* write OOB first */
if (oob_required &&
!is_all_ff(chip->oob_poi, mtd->oobsize)) {
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 20, 0)
err = ar934x_nfc_write_oob(mtd, chip, page);
#else
err = ar934x_nfc_write_oob(chip, page);
#endif
if (err)
return err;
}
@ -997,14 +1082,22 @@ static int ar934x_nfc_write_page(struct mtd_info *mtd, struct nand_chip *chip,
return err;
}
static int ar934x_nfc_hw_reset_assert(struct ar934x_nfc *nfc) {
reset_control_assert(nfc->rst);
static int ar934x_nfc_hw_reset_assert(struct ar934x_nfc *nfc)
{
int err;
err = reset_control_assert(nfc->rst);
udelay(250);
return err;
}
static int ar934x_nfc_hw_reset_deassert(struct ar934x_nfc *nfc) {
reset_control_deassert(nfc->rst);
static int ar934x_nfc_hw_reset_deassert(struct ar934x_nfc *nfc)
{
int err;
err = reset_control_deassert(nfc->rst);
udelay(250);
return err;
}
static int ar934x_nfc_hw_init(struct ar934x_nfc *nfc)
@ -1083,6 +1176,11 @@ static int ar934x_nfc_init_tail(struct mtd_info *mtd)
{
struct ar934x_nfc *nfc = mtd_to_ar934x_nfc(mtd);
struct nand_chip *chip = &nfc->nand_chip;
#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 2, 0)
u64 chipsize = chip->chipsize;
#else
u64 chipsize = nanddev_target_size(&chip->base);
#endif
u32 ctrl;
u32 t;
int err;
@ -1169,10 +1267,10 @@ static int ar934x_nfc_init_tail(struct mtd_info *mtd)
if (nfc->small_page) {
ctrl |= AR934X_NFC_CTRL_SMALL_PAGE;
if (chip->chipsize > (32 << 20)) {
if (chipsize > (32 << 20)) {
nfc->addr_count0 = 4;
nfc->addr_count1 = 3;
} else if (chip->chipsize > (2 << 16)) {
} else if (chipsize > (2 << 16)) {
nfc->addr_count0 = 3;
nfc->addr_count1 = 2;
} else {
@ -1180,10 +1278,10 @@ static int ar934x_nfc_init_tail(struct mtd_info *mtd)
nfc->addr_count1 = 1;
}
} else {
if (chip->chipsize > (128 << 20)) {
if (chipsize > (128 << 20)) {
nfc->addr_count0 = 5;
nfc->addr_count1 = 3;
} else if (chip->chipsize > (8 << 16)) {
} else if (chipsize > (8 << 16)) {
nfc->addr_count0 = 4;
nfc->addr_count1 = 2;
} else {
@ -1329,8 +1427,13 @@ static int ar934x_nfc_attach_chip(struct nand_chip *nand)
static u64 ar934x_nfc_dma_mask = DMA_BIT_MASK(32);
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 20, 0)
static void ar934x_nfc_cmd_ctrl(struct mtd_info *mtd, int dat,
unsigned int ctrl)
#else
static void ar934x_nfc_cmd_ctrl(struct nand_chip *chip, int dat,
unsigned int ctrl)
#endif
{
WARN_ON(dat != NAND_CMD_NONE);
}
@ -1401,6 +1504,7 @@ static int ar934x_nfc_probe(struct platform_device *pdev)
nand_set_controller_data(nand, nfc);
nand_set_flash_node(nand, pdev->dev.of_node);
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 20, 0)
nand->chip_delay = 25;
nand->dev_ready = ar934x_nfc_dev_ready;
nand->cmdfunc = ar934x_nfc_cmdfunc;
@ -1408,7 +1512,17 @@ static int ar934x_nfc_probe(struct platform_device *pdev)
nand->read_byte = ar934x_nfc_read_byte;
nand->write_buf = ar934x_nfc_write_buf;
nand->read_buf = ar934x_nfc_read_buf;
#else
nand->legacy.chip_delay = 25;
nand->legacy.dev_ready = ar934x_nfc_dev_ready;
nand->legacy.cmdfunc = ar934x_nfc_cmdfunc;
nand->legacy.cmd_ctrl = ar934x_nfc_cmd_ctrl; /* dummy */
nand->legacy.read_byte = ar934x_nfc_read_byte;
nand->legacy.write_buf = ar934x_nfc_write_buf;
nand->legacy.read_buf = ar934x_nfc_read_buf;
#endif
nand->ecc.mode = NAND_ECC_HW; /* default */
nand->priv = nfc;
platform_set_drvdata(pdev, nfc);
ret = ar934x_nfc_alloc_buf(nfc, AR934X_NFC_ID_BUF_SIZE);
@ -1421,8 +1535,16 @@ static int ar934x_nfc_probe(struct platform_device *pdev)
goto err_free_buf;
}
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 19, 130)
nand->dummy_controller.ops = &ar934x_nfc_controller_ops;
ret = nand_scan(mtd, 1);
#elif LINUX_VERSION_CODE < KERNEL_VERSION(4, 20, 0)
nand->dummy_controller.ops = &ar934x_nfc_controller_ops;
ret = nand_scan(nand, 1);
#else
nand->legacy.dummy_controller.ops = &ar934x_nfc_controller_ops;
ret = nand_scan(nand, 1);
#endif
if (ret) {
dev_err(&pdev->dev, "nand_scan failed, err:%d\n", ret);
goto err_free_buf;
@ -1444,12 +1566,13 @@ err_free_buf:
static int ar934x_nfc_remove(struct platform_device *pdev)
{
struct ar934x_nfc *nfc;
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 20, 0)
struct mtd_info *mtd;
#endif
nfc = platform_get_drvdata(pdev);
if (nfc) {
mtd = ar934x_nfc_to_mtd(nfc);
nand_release(mtd);
nand_release(&nfc->nand_chip);
ar934x_nfc_free_buf(nfc);
}

View File

@ -267,7 +267,7 @@
case IPV6_2292HOPOPTS:
--- a/net/ipv6/ip6_gre.c
+++ b/net/ipv6/ip6_gre.c
@@ -452,7 +452,7 @@ static void ip6gre_err(struct sk_buff *s
@@ -455,7 +455,7 @@ static void ip6gre_err(struct sk_buff *s
return;
ipv6h = (const struct ipv6hdr *)skb->data;
greh = (const struct gre_base_hdr *)(skb->data + offset);
@ -728,7 +728,7 @@
EXPORT_SYMBOL(xfrm_parse_spi);
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -3896,14 +3896,16 @@ static bool tcp_parse_aligned_timestamp(
@@ -3906,14 +3906,16 @@ static bool tcp_parse_aligned_timestamp(
{
const __be32 *ptr = (const __be32 *)(th + 1);

View File

@ -21,7 +21,7 @@ Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
#include "b53_regs.h"
#include "b53_priv.h"
@@ -1579,6 +1580,28 @@ static int b53_switch_init(struct b53_de
@@ -1587,6 +1588,28 @@ static int b53_switch_init(struct b53_de
return ret;
}

View File

@ -83,7 +83,7 @@ Signed-off-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
q->flows[reduced_hash].dsthost = dsthost_idx;
}
}
@@ -1793,20 +1797,30 @@ static s32 cake_enqueue(struct sk_buff *
@@ -1817,20 +1821,30 @@ static s32 cake_enqueue(struct sk_buff *
b->sparse_flow_count++;
if (cake_dsrc(q->flow_mode))
@ -116,7 +116,7 @@ Signed-off-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
}
if (q->buffer_used > q->buffer_max_used)
@@ -1974,23 +1988,8 @@ retry:
@@ -1998,23 +2012,8 @@ retry:
dsthost = &b->hosts[flow->dsthost];
host_load = 1;
@ -140,7 +140,7 @@ Signed-off-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
/* Keep all flows with deficits out of the sparse and decaying
* rotations. No non-empty flow can go into the decaying
* rotation, so they can't get deficits
@@ -1999,6 +1998,13 @@ retry:
@@ -2023,6 +2022,13 @@ retry:
if (flow->head) {
b->sparse_flow_count--;
b->bulk_flow_count++;
@ -154,7 +154,7 @@ Signed-off-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
flow->set = CAKE_SET_BULK;
} else {
/* we've moved it to the bulk rotation for
@@ -2008,6 +2014,22 @@ retry:
@@ -2032,6 +2038,22 @@ retry:
flow->set = CAKE_SET_SPARSE_WAIT;
}
}
@ -177,7 +177,7 @@ Signed-off-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
goto retry;
}
@@ -2028,6 +2050,13 @@ retry:
@@ -2052,6 +2074,13 @@ retry:
&b->decaying_flows);
if (flow->set == CAKE_SET_BULK) {
b->bulk_flow_count--;
@ -191,7 +191,7 @@ Signed-off-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
b->decaying_flow_count++;
} else if (flow->set == CAKE_SET_SPARSE ||
flow->set == CAKE_SET_SPARSE_WAIT) {
@@ -2041,14 +2070,19 @@ retry:
@@ -2065,14 +2094,19 @@ retry:
if (flow->set == CAKE_SET_SPARSE ||
flow->set == CAKE_SET_SPARSE_WAIT)
b->sparse_flow_count--;

View File

@ -91,7 +91,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
};
/* COBALT operates the Codel and BLUE algorithms in parallel, in order to
@@ -2623,6 +2624,13 @@ static int cake_change(struct Qdisc *sch
@@ -2647,6 +2648,13 @@ static int cake_change(struct Qdisc *sch
q->rate_flags &= ~CAKE_FLAG_SPLIT_GSO;
}
@ -105,7 +105,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
if (q->tins) {
sch_tree_lock(sch);
cake_reconfigure(sch);
@@ -2782,6 +2790,10 @@ static int cake_dump(struct Qdisc *sch,
@@ -2806,6 +2814,10 @@ static int cake_dump(struct Qdisc *sch,
!!(q->rate_flags & CAKE_FLAG_SPLIT_GSO)))
goto nla_put_failure;

View File

@ -52,24 +52,24 @@ Signed-off-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
};
/* COBALT operates the Codel and BLUE algorithms in parallel, in order to
@@ -1554,7 +1556,7 @@ static struct cake_tin_data *cake_select
@@ -1573,7 +1575,7 @@ static struct cake_tin_data *cake_select
struct sk_buff *skb)
{
struct cake_sched_data *q = qdisc_priv(sch);
- u32 tin;
+ u32 tin, mark;
bool wash;
u8 dscp;
/* Tin selection: Default to diffserv-based selection, allow overriding
@@ -1562,6 +1564,7 @@ static struct cake_tin_data *cake_select
*/
dscp = cake_handle_diffserv(skb,
q->rate_flags & CAKE_FLAG_WASH);
@@ -1584,6 +1586,7 @@ static struct cake_tin_data *cake_select
wash = !!(q->rate_flags & CAKE_FLAG_WASH);
if (wash)
dscp = cake_handle_diffserv(skb, wash);
+ mark = (skb->mark & q->fwmark_mask) >> q->fwmark_shft;
if (q->tin_mode == CAKE_DIFFSERV_BESTEFFORT)
tin = 0;
@@ -2178,6 +2181,7 @@ static const struct nla_policy cake_poli
@@ -2202,6 +2205,7 @@ static const struct nla_policy cake_poli
[TCA_CAKE_MPU] = { .type = NLA_U32 },
[TCA_CAKE_INGRESS] = { .type = NLA_U32 },
[TCA_CAKE_ACK_FILTER] = { .type = NLA_U32 },
@ -77,7 +77,7 @@ Signed-off-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
};
static void cake_set_rate(struct cake_tin_data *b, u64 rate, u32 mtu,
@@ -2625,10 +2629,8 @@ static int cake_change(struct Qdisc *sch
@@ -2649,10 +2653,8 @@ static int cake_change(struct Qdisc *sch
}
if (tb[TCA_CAKE_FWMARK]) {
@ -90,7 +90,7 @@ Signed-off-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
}
if (q->tins) {
@@ -2790,8 +2792,7 @@ static int cake_dump(struct Qdisc *sch,
@@ -2814,8 +2816,7 @@ static int cake_dump(struct Qdisc *sch,
!!(q->rate_flags & CAKE_FLAG_SPLIT_GSO)))
goto nla_put_failure;

View File

@ -32,7 +32,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
s32 tin_deficit;
u32 tin_backlog;
u32 tin_dropped;
@@ -1916,7 +1915,7 @@ begin:
@@ -1940,7 +1939,7 @@ begin:
while (b->tin_deficit < 0 ||
!(b->sparse_flow_count + b->bulk_flow_count)) {
if (b->tin_deficit <= 0)
@ -41,7 +41,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
if (b->sparse_flow_count + b->bulk_flow_count)
empty = false;
@@ -2237,8 +2236,7 @@ static int cake_config_besteffort(struct
@@ -2261,8 +2260,7 @@ static int cake_config_besteffort(struct
cake_set_rate(b, rate, mtu,
us_to_ns(q->target), us_to_ns(q->interval));
@ -51,7 +51,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
return 0;
}
@@ -2249,8 +2247,7 @@ static int cake_config_precedence(struct
@@ -2273,8 +2271,7 @@ static int cake_config_precedence(struct
struct cake_sched_data *q = qdisc_priv(sch);
u32 mtu = psched_mtu(qdisc_dev(sch));
u64 rate = q->rate_bps;
@ -61,7 +61,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
u32 i;
q->tin_cnt = 8;
@@ -2263,18 +2260,14 @@ static int cake_config_precedence(struct
@@ -2287,18 +2284,14 @@ static int cake_config_precedence(struct
cake_set_rate(b, rate, mtu, us_to_ns(q->target),
us_to_ns(q->interval));
@ -83,7 +83,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
}
return 0;
@@ -2343,8 +2336,7 @@ static int cake_config_diffserv8(struct
@@ -2367,8 +2360,7 @@ static int cake_config_diffserv8(struct
struct cake_sched_data *q = qdisc_priv(sch);
u32 mtu = psched_mtu(qdisc_dev(sch));
u64 rate = q->rate_bps;
@ -93,7 +93,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
u32 i;
q->tin_cnt = 8;
@@ -2360,18 +2352,14 @@ static int cake_config_diffserv8(struct
@@ -2384,18 +2376,14 @@ static int cake_config_diffserv8(struct
cake_set_rate(b, rate, mtu, us_to_ns(q->target),
us_to_ns(q->interval));
@ -115,7 +115,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
}
return 0;
@@ -2410,17 +2398,11 @@ static int cake_config_diffserv4(struct
@@ -2434,17 +2422,11 @@ static int cake_config_diffserv4(struct
cake_set_rate(&q->tins[3], rate >> 2, mtu,
us_to_ns(q->target), us_to_ns(q->interval));
@ -137,7 +137,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
return 0;
}
@@ -2451,15 +2433,10 @@ static int cake_config_diffserv3(struct
@@ -2475,15 +2457,10 @@ static int cake_config_diffserv3(struct
cake_set_rate(&q->tins[2], rate >> 2, mtu,
us_to_ns(q->target), us_to_ns(q->interval));

View File

@ -20,7 +20,7 @@ Signed-off-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
--- a/net/sched/sch_cake.c
+++ b/net/sched/sch_cake.c
@@ -2180,6 +2180,7 @@ static const struct nla_policy cake_poli
@@ -2204,6 +2204,7 @@ static const struct nla_policy cake_poli
[TCA_CAKE_MPU] = { .type = NLA_U32 },
[TCA_CAKE_INGRESS] = { .type = NLA_U32 },
[TCA_CAKE_ACK_FILTER] = { .type = NLA_U32 },

View File

@ -1,96 +0,0 @@
From 9208d2863ac689a563b92f2161d8d1e7127d0add Mon Sep 17 00:00:00 2001
From: Ilya Ponetayev <i.ponetaev@ndmsystems.com>
Date: Thu, 25 Jun 2020 22:12:07 +0200
Subject: [PATCH] sch_cake: don't try to reallocate or unshare skb
unconditionally
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
cake_handle_diffserv() tries to linearize mac and network header parts of
skb and to make it writable unconditionally. In some cases it leads to full
skb reallocation, which reduces throughput and increases CPU load. Some
measurements of IPv4 forward + NAPT on MIPS router with 580 MHz single-core
CPU was conducted. It appears that on kernel 4.9 skb_try_make_writable()
reallocates skb, if skb was allocated in ethernet driver via so-called
'build skb' method from page cache (it was discovered by strange increase
of kmalloc-2048 slab at first).
Obtain DSCP value via read-only skb_header_pointer() call, and leave
linearization only for DSCP bleaching or ECN CE setting. And, as an
additional optimisation, skip diffserv parsing entirely if it is not needed
by the current configuration.
Fixes: c87b4ecdbe8d ("sch_cake: Make sure we can write the IP header before changing DSCP bits")
Signed-off-by: Ilya Ponetayev <i.ponetaev@ndmsystems.com>
[ fix a few style issues, reflow commit message ]
Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
---
net/sched/sch_cake.c | 41 ++++++++++++++++++++++++++++++-----------
1 file changed, 30 insertions(+), 11 deletions(-)
--- a/net/sched/sch_cake.c
+++ b/net/sched/sch_cake.c
@@ -1553,30 +1553,49 @@ static unsigned int cake_drop(struct Qdi
static u8 cake_handle_diffserv(struct sk_buff *skb, u16 wash)
{
- int wlen = skb_network_offset(skb);
+ const int offset = skb_network_offset(skb);
+ u16 *buf, buf_;
u8 dscp;
switch (tc_skb_protocol(skb)) {
case htons(ETH_P_IP):
- wlen += sizeof(struct iphdr);
- if (!pskb_may_pull(skb, wlen) ||
- skb_try_make_writable(skb, wlen))
+ buf = skb_header_pointer(skb, offset, sizeof(buf_), &buf_);
+ if (unlikely(!buf))
return 0;
- dscp = ipv4_get_dsfield(ip_hdr(skb)) >> 2;
- if (wash && dscp)
+ /* ToS is in the second byte of iphdr */
+ dscp = ipv4_get_dsfield((struct iphdr *)buf) >> 2;
+
+ if (wash && dscp) {
+ const int wlen = offset + sizeof(struct iphdr);
+
+ if (!pskb_may_pull(skb, wlen) ||
+ skb_try_make_writable(skb, wlen))
+ return 0;
+
ipv4_change_dsfield(ip_hdr(skb), INET_ECN_MASK, 0);
+ }
+
return dscp;
case htons(ETH_P_IPV6):
- wlen += sizeof(struct ipv6hdr);
- if (!pskb_may_pull(skb, wlen) ||
- skb_try_make_writable(skb, wlen))
+ buf = skb_header_pointer(skb, offset, sizeof(buf_), &buf_);
+ if (unlikely(!buf))
return 0;
- dscp = ipv6_get_dsfield(ipv6_hdr(skb)) >> 2;
- if (wash && dscp)
+ /* Traffic class is in the first and second bytes of ipv6hdr */
+ dscp = ipv6_get_dsfield((struct ipv6hdr *)buf) >> 2;
+
+ if (wash && dscp) {
+ const int wlen = offset + sizeof(struct ipv6hdr);
+
+ if (!pskb_may_pull(skb, wlen) ||
+ skb_try_make_writable(skb, wlen))
+ return 0;
+
ipv6_change_dsfield(ipv6_hdr(skb), INET_ECN_MASK, 0);
+ }
+
return dscp;
case htons(ETH_P_ARP):

View File

@ -1,62 +0,0 @@
From 8c95eca0bb8c4bd2231a0d581f1ad0d50c90488c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Toke=20H=C3=B8iland-J=C3=B8rgensen?= <toke@redhat.com>
Date: Thu, 25 Jun 2020 22:12:08 +0200
Subject: [PATCH] sch_cake: don't call diffserv parsing code when it is not
needed
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
As a further optimisation of the diffserv parsing codepath, we can skip it
entirely if CAKE is configured to neither use diffserv-based
classification, nor to zero out the diffserv bits.
Fixes: c87b4ecdbe8d ("sch_cake: Make sure we can write the IP header before changing DSCP bits")
Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
---
net/sched/sch_cake.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
--- a/net/sched/sch_cake.c
+++ b/net/sched/sch_cake.c
@@ -1551,7 +1551,7 @@ static unsigned int cake_drop(struct Qdi
return idx + (tin << 16);
}
-static u8 cake_handle_diffserv(struct sk_buff *skb, u16 wash)
+static u8 cake_handle_diffserv(struct sk_buff *skb, bool wash)
{
const int offset = skb_network_offset(skb);
u16 *buf, buf_;
@@ -1612,14 +1612,17 @@ static struct cake_tin_data *cake_select
{
struct cake_sched_data *q = qdisc_priv(sch);
u32 tin, mark;
+ bool wash;
u8 dscp;
/* Tin selection: Default to diffserv-based selection, allow overriding
- * using firewall marks or skb->priority.
+ * using firewall marks or skb->priority. Call DSCP parsing early if
+ * wash is enabled, otherwise defer to below to skip unneeded parsing.
*/
- dscp = cake_handle_diffserv(skb,
- q->rate_flags & CAKE_FLAG_WASH);
mark = (skb->mark & q->fwmark_mask) >> q->fwmark_shft;
+ wash = !!(q->rate_flags & CAKE_FLAG_WASH);
+ if (wash)
+ dscp = cake_handle_diffserv(skb, wash);
if (q->tin_mode == CAKE_DIFFSERV_BESTEFFORT)
tin = 0;
@@ -1630,6 +1633,8 @@ static struct cake_tin_data *cake_select
tin = q->tin_order[TC_H_MIN(skb->priority) - 1];
else {
+ if (!wash)
+ dscp = cake_handle_diffserv(skb, wash);
tin = q->tin_index[dscp];
if (unlikely(tin >= q->tin_cnt))

View File

@ -1,40 +0,0 @@
From 3f608f0c41360b11b04c763f348b712f651c8bac Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Toke=20H=C3=B8iland-J=C3=B8rgensen?= <toke@redhat.com>
Date: Thu, 25 Jun 2020 22:12:09 +0200
Subject: [PATCH] sch_cake: fix a few style nits
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
I spotted a few nits when comparing the in-tree version of sch_cake with
the out-of-tree one: A redundant error variable declaration shadowing an
outer declaration, and an indentation alignment issue. Fix both of these.
Fixes: 046f6fd5daef ("sched: Add Common Applications Kept Enhanced (cake) qdisc")
Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
---
net/sched/sch_cake.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
--- a/net/sched/sch_cake.c
+++ b/net/sched/sch_cake.c
@@ -2713,7 +2713,7 @@ static int cake_init(struct Qdisc *sch,
qdisc_watchdog_init(&q->watchdog, sch);
if (opt) {
- int err = cake_change(sch, opt, extack);
+ err = cake_change(sch, opt, extack);
if (err)
return err;
@@ -3030,7 +3030,7 @@ static int cake_dump_class_stats(struct
PUT_STAT_S32(BLUE_TIMER_US,
ktime_to_us(
ktime_sub(now,
- flow->cvars.blue_timer)));
+ flow->cvars.blue_timer)));
}
if (flow->cvars.dropping) {
PUT_STAT_S32(DROP_NEXT_US,

View File

@ -17,7 +17,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -1781,6 +1781,19 @@ int phy_set_max_speed(struct phy_device
@@ -1783,6 +1783,19 @@ int phy_set_max_speed(struct phy_device
}
EXPORT_SYMBOL(phy_set_max_speed);

View File

@ -17,7 +17,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -1794,6 +1794,36 @@ void phy_support_asym_pause(struct phy_d
@@ -1796,6 +1796,36 @@ void phy_support_asym_pause(struct phy_d
}
EXPORT_SYMBOL(phy_support_asym_pause);

View File

@ -29,7 +29,7 @@ Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -890,8 +890,6 @@ int phy_init_hw(struct phy_device *phyde
@@ -892,8 +892,6 @@ int phy_init_hw(struct phy_device *phyde
if (phydev->drv->soft_reset)
ret = phydev->drv->soft_reset(phydev);

View File

@ -54,7 +54,7 @@ Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
#include <linux/mdio.h>
#include <linux/io.h>
#include <linux/uaccess.h>
@@ -948,6 +949,65 @@ void phy_attached_print(struct phy_devic
@@ -950,6 +951,65 @@ void phy_attached_print(struct phy_devic
EXPORT_SYMBOL(phy_attached_print);
/**
@ -120,7 +120,7 @@ Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
* phy_attach_direct - attach a network device to a given PHY device pointer
* @dev: network device to attach
* @phydev: Pointer to phy_device to attach
@@ -1020,6 +1080,9 @@ int phy_attach_direct(struct net_device
@@ -1022,6 +1082,9 @@ int phy_attach_direct(struct net_device
phydev->attached_dev = dev;
dev->phydev = phydev;
@ -130,7 +130,7 @@ Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
/* Some Ethernet drivers try to connect to a PHY device before
* calling register_netdevice() -> netdev_register_kobject() and
* does the dev->dev.kobj initialization. Here we only check for
@@ -1954,6 +2017,9 @@ static int phy_remove(struct device *dev
@@ -1956,6 +2019,9 @@ static int phy_remove(struct device *dev
phydev->state = PHY_DOWN;
mutex_unlock(&phydev->lock);

View File

@ -46,7 +46,7 @@ Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
continue;
if ((phydrv->phy_id & phydrv->phy_id_mask) ==
@@ -627,10 +627,13 @@ static int get_phy_id(struct mii_bus *bu
@@ -629,10 +629,13 @@ static int get_phy_id(struct mii_bus *bu
*/
struct phy_device *get_phy_device(struct mii_bus *bus, int addr, bool is_c45)
{

View File

@ -17,7 +17,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
depends on NETFILTER_ADVANCED
help
H.323 is a VoIP signalling protocol from ITU-T. As one of the most
@@ -1089,7 +1088,6 @@ config NETFILTER_XT_TARGET_SECMARK
@@ -1077,7 +1076,6 @@ config NETFILTER_XT_TARGET_SECMARK
config NETFILTER_XT_TARGET_TCPMSS
tristate '"TCPMSS" target support'

View File

@ -91,7 +91,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
#include <linux/mutex.h>
#include <linux/err.h>
#include <linux/of.h>
@@ -3039,3 +3040,5 @@ static int __init regmap_initcall(void)
@@ -3040,3 +3041,5 @@ static int __init regmap_initcall(void)
return 0;
}
postcore_initcall(regmap_initcall);

View File

@ -83,7 +83,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
EXPORT_SYMBOL(default_qdisc_ops);
/* Main transmission queue. */
@@ -1033,7 +1033,7 @@ static void attach_one_default_qdisc(str
@@ -1026,7 +1026,7 @@ static void attach_one_default_qdisc(str
void *_unused)
{
struct Qdisc *qdisc;

View File

@ -10,7 +10,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
--- a/net/sched/sch_generic.c
+++ b/net/sched/sch_generic.c
@@ -620,207 +620,6 @@ struct Qdisc_ops noqueue_qdisc_ops __rea
@@ -613,207 +613,6 @@ struct Qdisc_ops noqueue_qdisc_ops __rea
.owner = THIS_MODULE,
};

View File

@ -15,7 +15,7 @@
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -1581,6 +1581,9 @@ int genphy_update_link(struct phy_device
@@ -1583,6 +1583,9 @@ int genphy_update_link(struct phy_device
{
int status;

View File

@ -56,7 +56,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
*/
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -2566,6 +2566,10 @@ static inline int pskb_trim(struct sk_bu
@@ -2547,6 +2547,10 @@ static inline int pskb_trim(struct sk_bu
return (len < skb->len) ? __pskb_trim(skb, len) : 0;
}
@ -67,7 +67,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
/**
* pskb_trim_unique - remove end from a paged unique (not cloned) buffer
* @skb: buffer to alter
@@ -2697,16 +2701,6 @@ static inline struct sk_buff *dev_alloc_
@@ -2678,16 +2682,6 @@ static inline struct sk_buff *dev_alloc_
}
@ -101,7 +101,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
help
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -3259,10 +3259,20 @@ static int xmit_one(struct sk_buff *skb,
@@ -3251,10 +3251,20 @@ static int xmit_one(struct sk_buff *skb,
#endif
dev_queue_xmit_nit(skb, dev);
@ -136,7 +136,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
#include <net/protocol.h>
#include <net/dst.h>
@@ -555,6 +556,22 @@ skb_fail:
@@ -503,6 +504,22 @@ skb_fail:
}
EXPORT_SYMBOL(__napi_alloc_skb);

View File

@ -61,7 +61,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
struct dst_entry *__sk_dst_check(struct sock *sk, u32 cookie)
{
struct dst_entry *dst = __sk_dst_get(sk);
@@ -1603,9 +1615,11 @@ static void __sk_free(struct sock *sk)
@@ -1604,9 +1616,11 @@ static void __sk_free(struct sock *sk)
if (likely(sk->sk_net_refcnt))
sock_inuse_add(sock_net(sk), -1);

View File

@ -327,7 +327,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -3489,6 +3489,8 @@ static __net_initdata struct pernet_oper
@@ -3491,6 +3491,8 @@ static __net_initdata struct pernet_oper
static int __init proto_init(void)
{

View File

@ -22,7 +22,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
+KBUILD_CFLAGS += -Os $(EXTRA_OPTIMIZATION)
else
-KBUILD_CFLAGS += -O2
+KBUILD_CFLAGS += -O2 $(EXTRA_OPTIMIZATION)
+KBUILD_CFLAGS += -O2 -fno-reorder-blocks -fno-tree-ch $(EXTRA_OPTIMIZATION)
endif
# Tell gcc to never replace conditional load with a non-conditional one

View File

@ -9,7 +9,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -2530,7 +2530,7 @@ static inline int pskb_network_may_pull(
@@ -2511,7 +2511,7 @@ static inline int pskb_network_may_pull(
* NET_IP_ALIGN(2) + ethernet_header(14) + IP_header(20/40) + ports(8)
*/
#ifndef NET_SKB_PAD

View File

@ -11,7 +11,7 @@ Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -1205,6 +1205,9 @@ void phy_detach(struct phy_device *phyde
@@ -1207,6 +1207,9 @@ void phy_detach(struct phy_device *phyde
struct module *ndev_owner = dev->dev.parent->driver->owner;
struct mii_bus *bus;