* Re: [PATCH v2 0/3] Add Renesas R8A77980 GEther support
From: David Miller @ 2018-05-20 3:25 UTC (permalink / raw)
To: sergei.shtylyov
Cc: netdev, devicetree, robh+dt, mark.rutland, linux-renesas-soc
In-Reply-To: <f30c98ff-f6da-9e7f-c637-49076a428885@cogentembedded.com>
From: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Date: Fri, 18 May 2018 21:28:29 +0300
> Here's a set of 3 patches against DaveM's 'net-next.git' repo. They (gradually)
> add R8A77980 GEther support to the 'sh_eth' driver, starting with couple new
> register bits/values introduced with this chip, and ending with adding a new
> 'struct sh_eth_cpu_data' instance connected to the new DT "compatible" prop
> value...
Series applied, thanks.
^ permalink raw reply
* Re: [PATCH 1/4] arcnet: com20020: Add com20020 io mapped version
From: kbuild test robot @ 2018-05-20 3:31 UTC (permalink / raw)
To: Andrea Greco
Cc: kbuild-all, tobin, andrea.greco.gapmilano, Andrea Greco,
Michael Grzeschik, linux-kernel, netdev
In-Reply-To: <20180517130529.2684-1-andrea.greco.gapmilano@gmail.com>
Hi Andrea,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on net-next/master]
[also build test WARNING on v4.17-rc5 next-20180517]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Andrea-Greco/arcnet-com20020-Add-com20020-io-mapped-version/20180520-083936
reproduce:
# apt-get install sparse
make ARCH=x86_64 allmodconfig
make C=1 CF=-D__CHECK_ENDIAN__
sparse warnings: (new ones prefixed by >>)
drivers/net/arcnet/com90xx.c:484:13: sparse: undefined identifier 'arcnet_readb'
drivers/net/arcnet/com90xx.c:534:28: sparse: undefined identifier 'arcnet_readb'
drivers/net/arcnet/com90xx.c:613:13: sparse: undefined identifier 'arcnet_readb'
drivers/net/arcnet/com90xx.c:233:21: sparse: undefined identifier 'arcnet_readb'
drivers/net/arcnet/com90xx.c:234:25: sparse: undefined identifier 'arcnet_readb'
drivers/net/arcnet/com90xx.c:247:17: sparse: undefined identifier 'arcnet_writeb'
drivers/net/arcnet/com90xx.c:248:21: sparse: undefined identifier 'arcnet_readb'
drivers/net/arcnet/com90xx.c:391:29: sparse: undefined identifier 'arcnet_readb'
drivers/net/arcnet/com90xx.c:405:33: sparse: undefined identifier 'arcnet_readb'
drivers/net/arcnet/com90xx.c:428:17: sparse: undefined identifier 'arcnet_writeb'
drivers/net/arcnet/com90xx.c:446:21: sparse: undefined identifier 'arcnet_readb'
>> drivers/net/arcnet/com90xx.c:233:33: sparse: call with no type!
drivers/net/arcnet/com90xx.c:234:25: sparse: call with no type!
drivers/net/arcnet/com90xx.c:247:30: sparse: call with no type!
drivers/net/arcnet/com90xx.c:248:33: sparse: call with no type!
drivers/net/arcnet/com90xx.c:391:41: sparse: call with no type!
drivers/net/arcnet/com90xx.c:405:33: sparse: call with no type!
drivers/net/arcnet/com90xx.c:428:30: sparse: call with no type!
drivers/net/arcnet/com90xx.c:446:33: sparse: call with no type!
drivers/net/arcnet/com90xx.c:484:25: sparse: call with no type!
drivers/net/arcnet/com90xx.c:485:25: sparse: call with no type!
drivers/net/arcnet/com90xx.c:486:25: sparse: call with no type!
drivers/net/arcnet/com90xx.c:534:40: sparse: call with no type!
drivers/net/arcnet/com90xx.c:613:25: sparse: call with no type!
>> drivers/net/arcnet/com90xx.c:615:25: sparse: unknown expression (4 0)
>> drivers/net/arcnet/com90xx.c:615:25: sparse: unknown expression (4 0)
>> drivers/net/arcnet/com90xx.c:615:25: sparse: unknown expression (4 0)
>> drivers/net/arcnet/com90xx.c:615:25: sparse: unknown expression (4 0)
In file included from drivers/net/arcnet/com90xx.c:40:0:
drivers/net/arcnet/com90xx.c: In function 'com90xx_probe':
drivers/net/arcnet/arcdevice.h:376:10: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
ioread8((void __iomem *)(addr) + BUS_ALIGN * offset)
^
drivers/net/arcnet/com90xx.c:161:7: note: in expansion of macro 'arcnet_inb'
if (arcnet_inb(ioaddr, COM9026_REG_R_STATUS) == 0xFF) {
^~~~~~~~~~
drivers/net/arcnet/arcdevice.h:376:10: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
ioread8((void __iomem *)(addr) + BUS_ALIGN * offset)
^
drivers/net/arcnet/com90xx.c:171:3: note: in expansion of macro 'arcnet_inb'
arcnet_inb(ioaddr, COM9026_REG_R_RESET);
^~~~~~~~~~
drivers/net/arcnet/com90xx.c:233:7: error: implicit declaration of function 'arcnet_readb'; did you mean 'arcnet_outsb'? [-Werror=implicit-function-declaration]
if (arcnet_readb(base, COM9026_REG_R_STATUS) != TESTvalue) {
^~~~~~~~~~~~
arcnet_outsb
drivers/net/arcnet/com90xx.c:247:3: error: implicit declaration of function 'arcnet_writeb'; did you mean 'arcnet_outsb'? [-Werror=implicit-function-declaration]
arcnet_writeb(0x42, base, COM9026_REG_W_INTMASK);
^~~~~~~~~~~~~
arcnet_outsb
In file included from drivers/net/arcnet/com90xx.c:40:0:
drivers/net/arcnet/arcdevice.h:376:10: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
ioread8((void __iomem *)(addr) + BUS_ALIGN * offset)
^
drivers/net/arcnet/com90xx.c:312:12: note: in expansion of macro 'arcnet_inb'
status = arcnet_inb(ioaddr, COM9026_REG_R_STATUS);
^~~~~~~~~~
drivers/net/arcnet/arcdevice.h:379:18: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
iowrite8(value, (void __iomem *)addr + BUS_ALIGN * offset)
^
drivers/net/arcnet/com90xx.c:324:3: note: in expansion of macro 'arcnet_outb'
arcnet_outb(CFLAGScmd | RESETclear | CONFIGclear,
^~~~~~~~~~~
drivers/net/arcnet/arcdevice.h:376:10: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
ioread8((void __iomem *)(addr) + BUS_ALIGN * offset)
^
drivers/net/arcnet/com90xx.c:326:12: note: in expansion of macro 'arcnet_inb'
status = arcnet_inb(ioaddr, COM9026_REG_R_STATUS);
^~~~~~~~~~
drivers/net/arcnet/arcdevice.h:379:18: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
iowrite8(value, (void __iomem *)addr + BUS_ALIGN * offset)
^
drivers/net/arcnet/com90xx.c:346:4: note: in expansion of macro 'arcnet_outb'
arcnet_outb(NORXflag, ioaddr, COM9026_REG_W_INTMASK);
^~~~~~~~~~~
drivers/net/arcnet/arcdevice.h:379:18: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
iowrite8(value, (void __iomem *)addr + BUS_ALIGN * offset)
^
drivers/net/arcnet/com90xx.c:348:4: note: in expansion of macro 'arcnet_outb'
arcnet_outb(0, ioaddr, COM9026_REG_W_INTMASK);
^~~~~~~~~~~
drivers/net/arcnet/arcdevice.h:376:10: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
ioread8((void __iomem *)(addr) + BUS_ALIGN * offset)
^
drivers/net/arcnet/com90xx.c:383:3: note: in expansion of macro 'arcnet_inb'
arcnet_inb(ioaddr, COM9026_REG_R_RESET);
^~~~~~~~~~
drivers/net/arcnet/com90xx.c: In function 'com90xx_command':
drivers/net/arcnet/arcdevice.h:379:18: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
iowrite8(value, (void __iomem *)addr + BUS_ALIGN * offset)
^
drivers/net/arcnet/com90xx.c:565:2: note: in expansion of macro 'arcnet_outb'
arcnet_outb(cmd, ioaddr, COM9026_REG_W_COMMAND);
^~~~~~~~~~~
drivers/net/arcnet/com90xx.c: In function 'com90xx_status':
drivers/net/arcnet/arcdevice.h:376:10: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
ioread8((void __iomem *)(addr) + BUS_ALIGN * offset)
^
drivers/net/arcnet/com90xx.c:572:9: note: in expansion of macro 'arcnet_inb'
return arcnet_inb(ioaddr, COM9026_REG_R_STATUS);
^~~~~~~~~~
drivers/net/arcnet/com90xx.c: In function 'com90xx_setmask':
drivers/net/arcnet/arcdevice.h:379:18: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
iowrite8(value, (void __iomem *)addr + BUS_ALIGN * offset)
^
drivers/net/arcnet/com90xx.c:579:2: note: in expansion of macro 'arcnet_outb'
arcnet_outb(mask, ioaddr, COM9026_REG_W_INTMASK);
^~~~~~~~~~~
drivers/net/arcnet/com90xx.c: In function 'com90xx_reset':
drivers/net/arcnet/arcdevice.h:376:10: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
ioread8((void __iomem *)(addr) + BUS_ALIGN * offset)
^
drivers/net/arcnet/arcdevice.h:88:28: note: in expansion of macro 'arcnet_inb'
netdev_warn(dev, fmt, ##__VA_ARGS__); 115- ^~~~~~~~~~~
drivers/net/arcnet/com90xx.c:594:2: note: in expansion of macro 'arc_printk'
arc_printk(D_INIT, dev, "Resetting (status=%02Xh)n",
^~~~~~~~~~
drivers/net/arcnet/arcdevice.h:376:10: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
ioread8((void __iomem *)(addr) + BUS_ALIGN * offset)
^
drivers/net/arcnet/arcdevice.h:90:28: note: in expansion of macro 'arcnet_inb'
netdev_info(dev, fmt, ##__VA_ARGS__); 124- ^~~~~~~~~~~
drivers/net/arcnet/com90xx.c:594:2: note: in expansion of macro 'arc_printk'
arc_printk(D_INIT, dev, "Resetting (status=%02Xh)n",
^~~~~~~~~~
drivers/net/arcnet/arcdevice.h:376:10: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
--
drivers/net/arcnet/arc-rimi.c:147:9: sparse: undefined identifier 'arcnet_writeb'
drivers/net/arcnet/arc-rimi.c:148:9: sparse: undefined identifier 'arcnet_writeb'
drivers/net/arcnet/arc-rimi.c:158:13: sparse: undefined identifier 'arcnet_readb'
drivers/net/arcnet/arc-rimi.c:210:28: sparse: undefined identifier 'arcnet_readb'
drivers/net/arcnet/arc-rimi.c:284:9: sparse: undefined identifier 'arcnet_writeb'
drivers/net/arcnet/arc-rimi.c:276:16: sparse: undefined identifier 'arcnet_readb'
drivers/net/arcnet/arc-rimi.c:268:9: sparse: undefined identifier 'arcnet_writeb'
drivers/net/arcnet/arc-rimi.c:245:9: sparse: undefined identifier 'arcnet_readb'
drivers/net/arcnet/arc-rimi.c:245:9: sparse: undefined identifier 'arcnet_readb'
drivers/net/arcnet/arc-rimi.c:245:9: sparse: undefined identifier 'arcnet_readb'
drivers/net/arcnet/arc-rimi.c:249:17: sparse: undefined identifier 'arcnet_writeb'
drivers/net/arcnet/arc-rimi.c:253:9: sparse: undefined identifier 'arcnet_writeb'
drivers/net/arcnet/arc-rimi.c:254:9: sparse: undefined identifier 'arcnet_writeb'
drivers/net/arcnet/arc-rimi.c:257:9: sparse: undefined identifier 'arcnet_writeb'
drivers/net/arcnet/arc-rimi.c:109:21: sparse: undefined identifier 'arcnet_readb'
>> drivers/net/arcnet/arc-rimi.c:109:33: sparse: call with no type!
drivers/net/arcnet/arc-rimi.c:147:22: sparse: call with no type!
drivers/net/arcnet/arc-rimi.c:148:22: sparse: call with no type!
drivers/net/arcnet/arc-rimi.c:158:25: sparse: call with no type!
drivers/net/arcnet/arc-rimi.c:159:25: sparse: call with no type!
drivers/net/arcnet/arc-rimi.c:160:25: sparse: call with no type!
drivers/net/arcnet/arc-rimi.c:210:40: sparse: call with no type!
drivers/net/arcnet/arc-rimi.c:245:9: sparse: call with no type!
drivers/net/arcnet/arc-rimi.c:245:9: sparse: call with no type!
drivers/net/arcnet/arc-rimi.c:245:9: sparse: call with no type!
drivers/net/arcnet/arc-rimi.c:249:30: sparse: call with no type!
drivers/net/arcnet/arc-rimi.c:253:22: sparse: call with no type!
drivers/net/arcnet/arc-rimi.c:254:22: sparse: call with no type!
drivers/net/arcnet/arc-rimi.c:257:22: sparse: call with no type!
drivers/net/arcnet/arc-rimi.c:268:22: sparse: call with no type!
drivers/net/arcnet/arc-rimi.c:276:28: sparse: call with no type!
drivers/net/arcnet/arc-rimi.c:284:22: sparse: call with no type!
drivers/net/arcnet/arc-rimi.c: In function 'check_mirror':
drivers/net/arcnet/arc-rimi.c:109:7: error: implicit declaration of function 'arcnet_readb'; did you mean 'arcnet_outsb'? [-Werror=implicit-function-declaration]
if (arcnet_readb(p, COM9026_REG_R_STATUS) == TESTvalue)
^~~~~~~~~~~~
arcnet_outsb
drivers/net/arcnet/arc-rimi.c: In function 'arcrimi_found':
drivers/net/arcnet/arc-rimi.c:147:2: error: implicit declaration of function 'arcnet_writeb'; did you mean 'arcnet_outsb'? [-Werror=implicit-function-declaration]
arcnet_writeb(TESTvalue, p, COM9026_REG_W_INTMASK);
^~~~~~~~~~~~~
arcnet_outsb
cc1: some warnings being treated as errors
vim +233 drivers/net/arcnet/com90xx.c
^1da177e4 Linus Torvalds 2005-04-16 95
^1da177e4 Linus Torvalds 2005-04-16 96 static void __init com90xx_probe(void)
^1da177e4 Linus Torvalds 2005-04-16 97 {
^1da177e4 Linus Torvalds 2005-04-16 98 int count, status, ioaddr, numprint, airq, openparen = 0;
^1da177e4 Linus Torvalds 2005-04-16 99 unsigned long airqmask;
7f5e760c1 Joe Perches 2015-05-05 100 int ports[(0x3f0 - 0x200) / 16 + 1] = { 0 };
d0f6ecad3 Al Viro 2005-12-02 101 unsigned long *shmems;
d0f6ecad3 Al Viro 2005-12-02 102 void __iomem **iomem;
^1da177e4 Linus Torvalds 2005-04-16 103 int numports, numshmems, *port;
^1da177e4 Linus Torvalds 2005-04-16 104 u_long *p;
d0f6ecad3 Al Viro 2005-12-02 105 int index;
^1da177e4 Linus Torvalds 2005-04-16 106
^1da177e4 Linus Torvalds 2005-04-16 107 if (!io && !irq && !shmem && !*device && com90xx_skip_probe)
^1da177e4 Linus Torvalds 2005-04-16 108 return;
^1da177e4 Linus Torvalds 2005-04-16 109
15901dc93 Andrew Morton 2006-04-01 110 shmems = kzalloc(((0x100000 - 0xa0000) / 0x800) * sizeof(unsigned long),
d0f6ecad3 Al Viro 2005-12-02 111 GFP_KERNEL);
d0f6ecad3 Al Viro 2005-12-02 112 if (!shmems)
d0f6ecad3 Al Viro 2005-12-02 113 return;
15901dc93 Andrew Morton 2006-04-01 114 iomem = kzalloc(((0x100000 - 0xa0000) / 0x800) * sizeof(void __iomem *),
d0f6ecad3 Al Viro 2005-12-02 115 GFP_KERNEL);
d0f6ecad3 Al Viro 2005-12-02 116 if (!iomem) {
d0f6ecad3 Al Viro 2005-12-02 117 kfree(shmems);
d0f6ecad3 Al Viro 2005-12-02 118 return;
d0f6ecad3 Al Viro 2005-12-02 119 }
d0f6ecad3 Al Viro 2005-12-02 120
72aeea484 Joe Perches 2015-05-05 121 if (BUGLVL(D_NORMAL))
05a24b234 Joe Perches 2015-05-05 122 pr_info("%s\n", "COM90xx chipset support");
^1da177e4 Linus Torvalds 2005-04-16 123
^1da177e4 Linus Torvalds 2005-04-16 124 /* set up the arrays where we'll store the possible probe addresses */
^1da177e4 Linus Torvalds 2005-04-16 125 numports = numshmems = 0;
^1da177e4 Linus Torvalds 2005-04-16 126 if (io)
^1da177e4 Linus Torvalds 2005-04-16 127 ports[numports++] = io;
^1da177e4 Linus Torvalds 2005-04-16 128 else
^1da177e4 Linus Torvalds 2005-04-16 129 for (count = 0x200; count <= 0x3f0; count += 16)
^1da177e4 Linus Torvalds 2005-04-16 130 ports[numports++] = count;
^1da177e4 Linus Torvalds 2005-04-16 131 if (shmem)
^1da177e4 Linus Torvalds 2005-04-16 132 shmems[numshmems++] = shmem;
^1da177e4 Linus Torvalds 2005-04-16 133 else
^1da177e4 Linus Torvalds 2005-04-16 134 for (count = 0xA0000; count <= 0xFF800; count += 2048)
^1da177e4 Linus Torvalds 2005-04-16 135 shmems[numshmems++] = count;
^1da177e4 Linus Torvalds 2005-04-16 136
^1da177e4 Linus Torvalds 2005-04-16 137 /* Stage 1: abandon any reserved ports, or ones with status==0xFF
^1da177e4 Linus Torvalds 2005-04-16 138 * (empty), and reset any others by reading the reset port.
^1da177e4 Linus Torvalds 2005-04-16 139 */
^1da177e4 Linus Torvalds 2005-04-16 140 numprint = -1;
^1da177e4 Linus Torvalds 2005-04-16 141 for (port = &ports[0]; port - ports < numports; port++) {
^1da177e4 Linus Torvalds 2005-04-16 142 numprint++;
^1da177e4 Linus Torvalds 2005-04-16 143 numprint %= 8;
^1da177e4 Linus Torvalds 2005-04-16 144 if (!numprint) {
a34c0932c Joe Perches 2015-05-05 145 arc_cont(D_INIT, "\n");
a34c0932c Joe Perches 2015-05-05 146 arc_cont(D_INIT, "S1: ");
^1da177e4 Linus Torvalds 2005-04-16 147 }
a34c0932c Joe Perches 2015-05-05 148 arc_cont(D_INIT, "%Xh ", *port);
^1da177e4 Linus Torvalds 2005-04-16 149
^1da177e4 Linus Torvalds 2005-04-16 150 ioaddr = *port;
^1da177e4 Linus Torvalds 2005-04-16 151
d6d7d3ed5 Joe Perches 2015-05-05 152 if (!request_region(*port, ARCNET_TOTAL_SIZE,
d6d7d3ed5 Joe Perches 2015-05-05 153 "arcnet (90xx)")) {
a34c0932c Joe Perches 2015-05-05 154 arc_cont(D_INIT_REASONS, "(request_region)\n");
a34c0932c Joe Perches 2015-05-05 155 arc_cont(D_INIT_REASONS, "S1: ");
72aeea484 Joe Perches 2015-05-05 156 if (BUGLVL(D_INIT_REASONS))
72aeea484 Joe Perches 2015-05-05 157 numprint = 0;
^1da177e4 Linus Torvalds 2005-04-16 158 *port-- = ports[--numports];
^1da177e4 Linus Torvalds 2005-04-16 159 continue;
^1da177e4 Linus Torvalds 2005-04-16 160 }
09dfbcd5d Joe Perches 2015-05-05 161 if (arcnet_inb(ioaddr, COM9026_REG_R_STATUS) == 0xFF) {
a34c0932c Joe Perches 2015-05-05 162 arc_cont(D_INIT_REASONS, "(empty)\n");
a34c0932c Joe Perches 2015-05-05 163 arc_cont(D_INIT_REASONS, "S1: ");
72aeea484 Joe Perches 2015-05-05 164 if (BUGLVL(D_INIT_REASONS))
72aeea484 Joe Perches 2015-05-05 165 numprint = 0;
^1da177e4 Linus Torvalds 2005-04-16 166 release_region(*port, ARCNET_TOTAL_SIZE);
^1da177e4 Linus Torvalds 2005-04-16 167 *port-- = ports[--numports];
^1da177e4 Linus Torvalds 2005-04-16 168 continue;
^1da177e4 Linus Torvalds 2005-04-16 169 }
09dfbcd5d Joe Perches 2015-05-05 170 /* begin resetting card */
09dfbcd5d Joe Perches 2015-05-05 171 arcnet_inb(ioaddr, COM9026_REG_R_RESET);
^1da177e4 Linus Torvalds 2005-04-16 172
a34c0932c Joe Perches 2015-05-05 173 arc_cont(D_INIT_REASONS, "\n");
a34c0932c Joe Perches 2015-05-05 174 arc_cont(D_INIT_REASONS, "S1: ");
72aeea484 Joe Perches 2015-05-05 175 if (BUGLVL(D_INIT_REASONS))
72aeea484 Joe Perches 2015-05-05 176 numprint = 0;
^1da177e4 Linus Torvalds 2005-04-16 177 }
a34c0932c Joe Perches 2015-05-05 178 arc_cont(D_INIT, "\n");
^1da177e4 Linus Torvalds 2005-04-16 179
^1da177e4 Linus Torvalds 2005-04-16 180 if (!numports) {
a34c0932c Joe Perches 2015-05-05 181 arc_cont(D_NORMAL, "S1: No ARCnet cards found.\n");
d0f6ecad3 Al Viro 2005-12-02 182 kfree(shmems);
d0f6ecad3 Al Viro 2005-12-02 183 kfree(iomem);
^1da177e4 Linus Torvalds 2005-04-16 184 return;
^1da177e4 Linus Torvalds 2005-04-16 185 }
^1da177e4 Linus Torvalds 2005-04-16 186 /* Stage 2: we have now reset any possible ARCnet cards, so we can't
^1da177e4 Linus Torvalds 2005-04-16 187 * do anything until they finish. If D_INIT, print the list of
^1da177e4 Linus Torvalds 2005-04-16 188 * cards that are left.
^1da177e4 Linus Torvalds 2005-04-16 189 */
^1da177e4 Linus Torvalds 2005-04-16 190 numprint = -1;
^1da177e4 Linus Torvalds 2005-04-16 191 for (port = &ports[0]; port < ports + numports; port++) {
^1da177e4 Linus Torvalds 2005-04-16 192 numprint++;
^1da177e4 Linus Torvalds 2005-04-16 193 numprint %= 8;
^1da177e4 Linus Torvalds 2005-04-16 194 if (!numprint) {
a34c0932c Joe Perches 2015-05-05 195 arc_cont(D_INIT, "\n");
a34c0932c Joe Perches 2015-05-05 196 arc_cont(D_INIT, "S2: ");
^1da177e4 Linus Torvalds 2005-04-16 197 }
a34c0932c Joe Perches 2015-05-05 198 arc_cont(D_INIT, "%Xh ", *port);
^1da177e4 Linus Torvalds 2005-04-16 199 }
a34c0932c Joe Perches 2015-05-05 200 arc_cont(D_INIT, "\n");
^1da177e4 Linus Torvalds 2005-04-16 201 mdelay(RESETtime);
^1da177e4 Linus Torvalds 2005-04-16 202
^1da177e4 Linus Torvalds 2005-04-16 203 /* Stage 3: abandon any shmem addresses that don't have the signature
^1da177e4 Linus Torvalds 2005-04-16 204 * 0xD1 byte in the right place, or are read-only.
^1da177e4 Linus Torvalds 2005-04-16 205 */
^1da177e4 Linus Torvalds 2005-04-16 206 numprint = -1;
d0f6ecad3 Al Viro 2005-12-02 207 for (index = 0, p = &shmems[0]; index < numshmems; p++, index++) {
d0f6ecad3 Al Viro 2005-12-02 208 void __iomem *base;
^1da177e4 Linus Torvalds 2005-04-16 209
^1da177e4 Linus Torvalds 2005-04-16 210 numprint++;
^1da177e4 Linus Torvalds 2005-04-16 211 numprint %= 8;
^1da177e4 Linus Torvalds 2005-04-16 212 if (!numprint) {
a34c0932c Joe Perches 2015-05-05 213 arc_cont(D_INIT, "\n");
a34c0932c Joe Perches 2015-05-05 214 arc_cont(D_INIT, "S3: ");
^1da177e4 Linus Torvalds 2005-04-16 215 }
a34c0932c Joe Perches 2015-05-05 216 arc_cont(D_INIT, "%lXh ", *p);
^1da177e4 Linus Torvalds 2005-04-16 217
d0f6ecad3 Al Viro 2005-12-02 218 if (!request_mem_region(*p, MIRROR_SIZE, "arcnet (90xx)")) {
a34c0932c Joe Perches 2015-05-05 219 arc_cont(D_INIT_REASONS, "(request_mem_region)\n");
a34c0932c Joe Perches 2015-05-05 220 arc_cont(D_INIT_REASONS, "Stage 3: ");
72aeea484 Joe Perches 2015-05-05 221 if (BUGLVL(D_INIT_REASONS))
72aeea484 Joe Perches 2015-05-05 222 numprint = 0;
d0f6ecad3 Al Viro 2005-12-02 223 goto out;
d0f6ecad3 Al Viro 2005-12-02 224 }
d0f6ecad3 Al Viro 2005-12-02 225 base = ioremap(*p, MIRROR_SIZE);
d0f6ecad3 Al Viro 2005-12-02 226 if (!base) {
a34c0932c Joe Perches 2015-05-05 227 arc_cont(D_INIT_REASONS, "(ioremap)\n");
a34c0932c Joe Perches 2015-05-05 228 arc_cont(D_INIT_REASONS, "Stage 3: ");
72aeea484 Joe Perches 2015-05-05 229 if (BUGLVL(D_INIT_REASONS))
72aeea484 Joe Perches 2015-05-05 230 numprint = 0;
d0f6ecad3 Al Viro 2005-12-02 231 goto out1;
^1da177e4 Linus Torvalds 2005-04-16 232 }
a11a5442d Joe Perches 2015-05-05 @233 if (arcnet_readb(base, COM9026_REG_R_STATUS) != TESTvalue) {
a34c0932c Joe Perches 2015-05-05 234 arc_cont(D_INIT_REASONS, "(%02Xh != %02Xh)\n",
a11a5442d Joe Perches 2015-05-05 235 arcnet_readb(base, COM9026_REG_R_STATUS),
a11a5442d Joe Perches 2015-05-05 236 TESTvalue);
a34c0932c Joe Perches 2015-05-05 237 arc_cont(D_INIT_REASONS, "S3: ");
72aeea484 Joe Perches 2015-05-05 238 if (BUGLVL(D_INIT_REASONS))
72aeea484 Joe Perches 2015-05-05 239 numprint = 0;
d0f6ecad3 Al Viro 2005-12-02 240 goto out2;
^1da177e4 Linus Torvalds 2005-04-16 241 }
^1da177e4 Linus Torvalds 2005-04-16 242 /* By writing 0x42 to the TESTvalue location, we also make
^1da177e4 Linus Torvalds 2005-04-16 243 * sure no "mirror" shmem areas show up - if they occur
^1da177e4 Linus Torvalds 2005-04-16 244 * in another pass through this loop, they will be discarded
^1da177e4 Linus Torvalds 2005-04-16 245 * because *cptr != TESTvalue.
^1da177e4 Linus Torvalds 2005-04-16 246 */
a11a5442d Joe Perches 2015-05-05 247 arcnet_writeb(0x42, base, COM9026_REG_W_INTMASK);
a11a5442d Joe Perches 2015-05-05 248 if (arcnet_readb(base, COM9026_REG_R_STATUS) != 0x42) {
a34c0932c Joe Perches 2015-05-05 249 arc_cont(D_INIT_REASONS, "(read only)\n");
a34c0932c Joe Perches 2015-05-05 250 arc_cont(D_INIT_REASONS, "S3: ");
d0f6ecad3 Al Viro 2005-12-02 251 goto out2;
^1da177e4 Linus Torvalds 2005-04-16 252 }
a34c0932c Joe Perches 2015-05-05 253 arc_cont(D_INIT_REASONS, "\n");
a34c0932c Joe Perches 2015-05-05 254 arc_cont(D_INIT_REASONS, "S3: ");
72aeea484 Joe Perches 2015-05-05 255 if (BUGLVL(D_INIT_REASONS))
72aeea484 Joe Perches 2015-05-05 256 numprint = 0;
d0f6ecad3 Al Viro 2005-12-02 257 iomem[index] = base;
d0f6ecad3 Al Viro 2005-12-02 258 continue;
d0f6ecad3 Al Viro 2005-12-02 259 out2:
d0f6ecad3 Al Viro 2005-12-02 260 iounmap(base);
d0f6ecad3 Al Viro 2005-12-02 261 out1:
d0f6ecad3 Al Viro 2005-12-02 262 release_mem_region(*p, MIRROR_SIZE);
d0f6ecad3 Al Viro 2005-12-02 263 out:
d0f6ecad3 Al Viro 2005-12-02 264 *p-- = shmems[--numshmems];
d0f6ecad3 Al Viro 2005-12-02 265 index--;
^1da177e4 Linus Torvalds 2005-04-16 266 }
a34c0932c Joe Perches 2015-05-05 267 arc_cont(D_INIT, "\n");
^1da177e4 Linus Torvalds 2005-04-16 268
^1da177e4 Linus Torvalds 2005-04-16 269 if (!numshmems) {
a34c0932c Joe Perches 2015-05-05 270 arc_cont(D_NORMAL, "S3: No ARCnet cards found.\n");
^1da177e4 Linus Torvalds 2005-04-16 271 for (port = &ports[0]; port < ports + numports; port++)
^1da177e4 Linus Torvalds 2005-04-16 272 release_region(*port, ARCNET_TOTAL_SIZE);
d0f6ecad3 Al Viro 2005-12-02 273 kfree(shmems);
d0f6ecad3 Al Viro 2005-12-02 274 kfree(iomem);
^1da177e4 Linus Torvalds 2005-04-16 275 return;
^1da177e4 Linus Torvalds 2005-04-16 276 }
^1da177e4 Linus Torvalds 2005-04-16 277 /* Stage 4: something of a dummy, to report the shmems that are
^1da177e4 Linus Torvalds 2005-04-16 278 * still possible after stage 3.
^1da177e4 Linus Torvalds 2005-04-16 279 */
^1da177e4 Linus Torvalds 2005-04-16 280 numprint = -1;
^1da177e4 Linus Torvalds 2005-04-16 281 for (p = &shmems[0]; p < shmems + numshmems; p++) {
^1da177e4 Linus Torvalds 2005-04-16 282 numprint++;
^1da177e4 Linus Torvalds 2005-04-16 283 numprint %= 8;
^1da177e4 Linus Torvalds 2005-04-16 284 if (!numprint) {
a34c0932c Joe Perches 2015-05-05 285 arc_cont(D_INIT, "\n");
a34c0932c Joe Perches 2015-05-05 286 arc_cont(D_INIT, "S4: ");
^1da177e4 Linus Torvalds 2005-04-16 287 }
a34c0932c Joe Perches 2015-05-05 288 arc_cont(D_INIT, "%lXh ", *p);
^1da177e4 Linus Torvalds 2005-04-16 289 }
a34c0932c Joe Perches 2015-05-05 290 arc_cont(D_INIT, "\n");
^1da177e4 Linus Torvalds 2005-04-16 291
^1da177e4 Linus Torvalds 2005-04-16 292 /* Stage 5: for any ports that have the correct status, can disable
^1da177e4 Linus Torvalds 2005-04-16 293 * the RESET flag, and (if no irq is given) generate an autoirq,
^1da177e4 Linus Torvalds 2005-04-16 294 * register an ARCnet device.
^1da177e4 Linus Torvalds 2005-04-16 295 *
^1da177e4 Linus Torvalds 2005-04-16 296 * Currently, we can only register one device per probe, so quit
^1da177e4 Linus Torvalds 2005-04-16 297 * after the first one is found.
^1da177e4 Linus Torvalds 2005-04-16 298 */
^1da177e4 Linus Torvalds 2005-04-16 299 numprint = -1;
^1da177e4 Linus Torvalds 2005-04-16 300 for (port = &ports[0]; port < ports + numports; port++) {
^1da177e4 Linus Torvalds 2005-04-16 301 int found = 0;
01a1d5ac4 Joe Perches 2015-05-05 302
^1da177e4 Linus Torvalds 2005-04-16 303 numprint++;
^1da177e4 Linus Torvalds 2005-04-16 304 numprint %= 8;
^1da177e4 Linus Torvalds 2005-04-16 305 if (!numprint) {
a34c0932c Joe Perches 2015-05-05 306 arc_cont(D_INIT, "\n");
a34c0932c Joe Perches 2015-05-05 307 arc_cont(D_INIT, "S5: ");
^1da177e4 Linus Torvalds 2005-04-16 308 }
a34c0932c Joe Perches 2015-05-05 309 arc_cont(D_INIT, "%Xh ", *port);
^1da177e4 Linus Torvalds 2005-04-16 310
^1da177e4 Linus Torvalds 2005-04-16 311 ioaddr = *port;
09dfbcd5d Joe Perches 2015-05-05 312 status = arcnet_inb(ioaddr, COM9026_REG_R_STATUS);
^1da177e4 Linus Torvalds 2005-04-16 313
^1da177e4 Linus Torvalds 2005-04-16 314 if ((status & 0x9D)
^1da177e4 Linus Torvalds 2005-04-16 315 != (NORXflag | RECONflag | TXFREEflag | RESETflag)) {
a34c0932c Joe Perches 2015-05-05 316 arc_cont(D_INIT_REASONS, "(status=%Xh)\n", status);
a34c0932c Joe Perches 2015-05-05 317 arc_cont(D_INIT_REASONS, "S5: ");
72aeea484 Joe Perches 2015-05-05 318 if (BUGLVL(D_INIT_REASONS))
72aeea484 Joe Perches 2015-05-05 319 numprint = 0;
^1da177e4 Linus Torvalds 2005-04-16 320 release_region(*port, ARCNET_TOTAL_SIZE);
^1da177e4 Linus Torvalds 2005-04-16 321 *port-- = ports[--numports];
^1da177e4 Linus Torvalds 2005-04-16 322 continue;
^1da177e4 Linus Torvalds 2005-04-16 323 }
09dfbcd5d Joe Perches 2015-05-05 324 arcnet_outb(CFLAGScmd | RESETclear | CONFIGclear,
09dfbcd5d Joe Perches 2015-05-05 325 ioaddr, COM9026_REG_W_COMMAND);
09dfbcd5d Joe Perches 2015-05-05 326 status = arcnet_inb(ioaddr, COM9026_REG_R_STATUS);
^1da177e4 Linus Torvalds 2005-04-16 327 if (status & RESETflag) {
a34c0932c Joe Perches 2015-05-05 328 arc_cont(D_INIT_REASONS, " (eternal reset, status=%Xh)\n",
^1da177e4 Linus Torvalds 2005-04-16 329 status);
a34c0932c Joe Perches 2015-05-05 330 arc_cont(D_INIT_REASONS, "S5: ");
72aeea484 Joe Perches 2015-05-05 331 if (BUGLVL(D_INIT_REASONS))
72aeea484 Joe Perches 2015-05-05 332 numprint = 0;
^1da177e4 Linus Torvalds 2005-04-16 333 release_region(*port, ARCNET_TOTAL_SIZE);
^1da177e4 Linus Torvalds 2005-04-16 334 *port-- = ports[--numports];
^1da177e4 Linus Torvalds 2005-04-16 335 continue;
^1da177e4 Linus Torvalds 2005-04-16 336 }
^1da177e4 Linus Torvalds 2005-04-16 337 /* skip this completely if an IRQ was given, because maybe
^1da177e4 Linus Torvalds 2005-04-16 338 * we're on a machine that locks during autoirq!
^1da177e4 Linus Torvalds 2005-04-16 339 */
^1da177e4 Linus Torvalds 2005-04-16 340 if (!irq) {
^1da177e4 Linus Torvalds 2005-04-16 341 /* if we do this, we're sure to get an IRQ since the
^1da177e4 Linus Torvalds 2005-04-16 342 * card has just reset and the NORXflag is on until
^1da177e4 Linus Torvalds 2005-04-16 343 * we tell it to start receiving.
^1da177e4 Linus Torvalds 2005-04-16 344 */
^1da177e4 Linus Torvalds 2005-04-16 345 airqmask = probe_irq_on();
09dfbcd5d Joe Perches 2015-05-05 346 arcnet_outb(NORXflag, ioaddr, COM9026_REG_W_INTMASK);
^1da177e4 Linus Torvalds 2005-04-16 347 udelay(1);
09dfbcd5d Joe Perches 2015-05-05 348 arcnet_outb(0, ioaddr, COM9026_REG_W_INTMASK);
^1da177e4 Linus Torvalds 2005-04-16 349 airq = probe_irq_off(airqmask);
^1da177e4 Linus Torvalds 2005-04-16 350
^1da177e4 Linus Torvalds 2005-04-16 351 if (airq <= 0) {
a34c0932c Joe Perches 2015-05-05 352 arc_cont(D_INIT_REASONS, "(airq=%d)\n", airq);
a34c0932c Joe Perches 2015-05-05 353 arc_cont(D_INIT_REASONS, "S5: ");
72aeea484 Joe Perches 2015-05-05 354 if (BUGLVL(D_INIT_REASONS))
72aeea484 Joe Perches 2015-05-05 355 numprint = 0;
^1da177e4 Linus Torvalds 2005-04-16 356 release_region(*port, ARCNET_TOTAL_SIZE);
^1da177e4 Linus Torvalds 2005-04-16 357 *port-- = ports[--numports];
^1da177e4 Linus Torvalds 2005-04-16 358 continue;
^1da177e4 Linus Torvalds 2005-04-16 359 }
^1da177e4 Linus Torvalds 2005-04-16 360 } else {
^1da177e4 Linus Torvalds 2005-04-16 361 airq = irq;
^1da177e4 Linus Torvalds 2005-04-16 362 }
^1da177e4 Linus Torvalds 2005-04-16 363
a34c0932c Joe Perches 2015-05-05 364 arc_cont(D_INIT, "(%d,", airq);
^1da177e4 Linus Torvalds 2005-04-16 365 openparen = 1;
^1da177e4 Linus Torvalds 2005-04-16 366
^1da177e4 Linus Torvalds 2005-04-16 367 /* Everything seems okay. But which shmem, if any, puts
^1da177e4 Linus Torvalds 2005-04-16 368 * back its signature byte when the card is reset?
^1da177e4 Linus Torvalds 2005-04-16 369 *
^1da177e4 Linus Torvalds 2005-04-16 370 * If there are multiple cards installed, there might be
^1da177e4 Linus Torvalds 2005-04-16 371 * multiple shmems still in the list.
^1da177e4 Linus Torvalds 2005-04-16 372 */
^1da177e4 Linus Torvalds 2005-04-16 373 #ifdef FAST_PROBE
^1da177e4 Linus Torvalds 2005-04-16 374 if (numports > 1 || numshmems > 1) {
09dfbcd5d Joe Perches 2015-05-05 375 arcnet_inb(ioaddr, COM9026_REG_R_RESET);
^1da177e4 Linus Torvalds 2005-04-16 376 mdelay(RESETtime);
^1da177e4 Linus Torvalds 2005-04-16 377 } else {
^1da177e4 Linus Torvalds 2005-04-16 378 /* just one shmem and port, assume they match */
a11a5442d Joe Perches 2015-05-05 379 arcnet_writeb(TESTvalue, iomem[0],
a11a5442d Joe Perches 2015-05-05 380 COM9026_REG_W_INTMASK);
^1da177e4 Linus Torvalds 2005-04-16 381 }
^1da177e4 Linus Torvalds 2005-04-16 382 #else
09dfbcd5d Joe Perches 2015-05-05 383 arcnet_inb(ioaddr, COM9026_REG_R_RESET);
^1da177e4 Linus Torvalds 2005-04-16 384 mdelay(RESETtime);
^1da177e4 Linus Torvalds 2005-04-16 385 #endif
^1da177e4 Linus Torvalds 2005-04-16 386
d0f6ecad3 Al Viro 2005-12-02 387 for (index = 0; index < numshmems; index++) {
d0f6ecad3 Al Viro 2005-12-02 388 u_long ptr = shmems[index];
d0f6ecad3 Al Viro 2005-12-02 389 void __iomem *base = iomem[index];
^1da177e4 Linus Torvalds 2005-04-16 390
a11a5442d Joe Perches 2015-05-05 @391 if (arcnet_readb(base, COM9026_REG_R_STATUS) == TESTvalue) { /* found one */
a34c0932c Joe Perches 2015-05-05 392 arc_cont(D_INIT, "%lXh)\n", *p);
^1da177e4 Linus Torvalds 2005-04-16 393 openparen = 0;
^1da177e4 Linus Torvalds 2005-04-16 394
^1da177e4 Linus Torvalds 2005-04-16 395 /* register the card */
d0f6ecad3 Al Viro 2005-12-02 396 if (com90xx_found(*port, airq, ptr, base) == 0)
^1da177e4 Linus Torvalds 2005-04-16 397 found = 1;
^1da177e4 Linus Torvalds 2005-04-16 398 numprint = -1;
^1da177e4 Linus Torvalds 2005-04-16 399
^1da177e4 Linus Torvalds 2005-04-16 400 /* remove shmem from the list */
d0f6ecad3 Al Viro 2005-12-02 401 shmems[index] = shmems[--numshmems];
d0f6ecad3 Al Viro 2005-12-02 402 iomem[index] = iomem[numshmems];
^1da177e4 Linus Torvalds 2005-04-16 403 break; /* go to the next I/O port */
^1da177e4 Linus Torvalds 2005-04-16 404 } else {
a11a5442d Joe Perches 2015-05-05 405 arc_cont(D_INIT_REASONS, "%Xh-",
a11a5442d Joe Perches 2015-05-05 406 arcnet_readb(base, COM9026_REG_R_STATUS));
^1da177e4 Linus Torvalds 2005-04-16 407 }
^1da177e4 Linus Torvalds 2005-04-16 408 }
^1da177e4 Linus Torvalds 2005-04-16 409
^1da177e4 Linus Torvalds 2005-04-16 410 if (openparen) {
72aeea484 Joe Perches 2015-05-05 411 if (BUGLVL(D_INIT))
05a24b234 Joe Perches 2015-05-05 412 pr_cont("no matching shmem)\n");
72aeea484 Joe Perches 2015-05-05 413 if (BUGLVL(D_INIT_REASONS)) {
05a24b234 Joe Perches 2015-05-05 414 pr_cont("S5: ");
72aeea484 Joe Perches 2015-05-05 415 numprint = 0;
72aeea484 Joe Perches 2015-05-05 416 }
^1da177e4 Linus Torvalds 2005-04-16 417 }
^1da177e4 Linus Torvalds 2005-04-16 418 if (!found)
^1da177e4 Linus Torvalds 2005-04-16 419 release_region(*port, ARCNET_TOTAL_SIZE);
^1da177e4 Linus Torvalds 2005-04-16 420 *port-- = ports[--numports];
^1da177e4 Linus Torvalds 2005-04-16 421 }
^1da177e4 Linus Torvalds 2005-04-16 422
72aeea484 Joe Perches 2015-05-05 423 if (BUGLVL(D_INIT_REASONS))
05a24b234 Joe Perches 2015-05-05 424 pr_cont("\n");
^1da177e4 Linus Torvalds 2005-04-16 425
^1da177e4 Linus Torvalds 2005-04-16 426 /* Now put back TESTvalue on all leftover shmems. */
d0f6ecad3 Al Viro 2005-12-02 427 for (index = 0; index < numshmems; index++) {
a11a5442d Joe Perches 2015-05-05 428 arcnet_writeb(TESTvalue, iomem[index], COM9026_REG_W_INTMASK);
d0f6ecad3 Al Viro 2005-12-02 429 iounmap(iomem[index]);
d0f6ecad3 Al Viro 2005-12-02 430 release_mem_region(shmems[index], MIRROR_SIZE);
^1da177e4 Linus Torvalds 2005-04-16 431 }
d0f6ecad3 Al Viro 2005-12-02 432 kfree(shmems);
d0f6ecad3 Al Viro 2005-12-02 433 kfree(iomem);
^1da177e4 Linus Torvalds 2005-04-16 434 }
^1da177e4 Linus Torvalds 2005-04-16 435
:::::: The code at line 233 was first introduced by commit
:::::: a11a5442d108357d44d34407ce2ed9d77ab424a0 arcnet: com90xx: Use arcnet_readb/writeb routines
:::::: TO: Joe Perches <joe@perches.com>
:::::: CC: Michael Grzeschik <m.grzeschik@pengutronix.de>
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
^ permalink raw reply
* Re: [PATCH net] net: ip6_gre: fix tunnel metadata device sharing.
From: David Miller @ 2018-05-20 3:33 UTC (permalink / raw)
To: u9012063; +Cc: netdev, petrm
In-Reply-To: <1526696548-8323-1-git-send-email-u9012063@gmail.com>
From: William Tu <u9012063@gmail.com>
Date: Fri, 18 May 2018 19:22:28 -0700
> Currently ip6gre and ip6erspan share single metadata mode device,
> using 'collect_md_tun'. Thus, when doing:
> ip link add dev ip6gre11 type ip6gretap external
> ip link add dev ip6erspan12 type ip6erspan external
> RTNETLINK answers: File exists
> simply fails due to the 2nd tries to create the same collect_md_tun.
>
> The patch fixes it by adding a separate collect md tunnel device
> for the ip6erspan, 'collect_md_tun_erspan'. As a result, a couple
> of places need to refactor/split up in order to distinguish ip6gre
> and ip6erspan.
>
> First, move the collect_md check at ip6gre_tunnel_{unlink,link} and
> create separate function {ip6gre,ip6ersapn}_tunnel_{link_md,unlink_md}.
> Then before link/unlink, make sure the link_md/unlink_md is called.
> Finally, a separate ndo_uninit is created for ip6erspan. Tested it
> using the samples/bpf/test_tunnel_bpf.sh.
>
> Fixes: ef7baf5e083c ("ip6_gre: add ip6 erspan collect_md mode")
> Signed-off-by: William Tu <u9012063@gmail.com>
Applied and queued up for -stable.
^ permalink raw reply
* Re: [PATCH 03/17] batman-adv: Add network_coding and mcast sysfs files to README
From: Sven Eckelmann @ 2018-05-20 4:37 UTC (permalink / raw)
To: Jiri Pirko
Cc: netdev-u79uwXL29TY76Z2rM5mHXA,
The list for a Better Approach To Mobile Ad-hoc Networking,
davem-fT/PcQaiUtIeIZ0/mPfg9Q
In-Reply-To: <2078208.hARaRF5Zct@bentobox>
[-- Attachment #1: Type: text/plain, Size: 1172 bytes --]
Hi Jiri,
seems like you still haven't answered Linus' question.
On Montag, 7. Mai 2018 08:34:16 CEST Sven Eckelmann wrote:
> On Dienstag, 27. März 2018 17:43:08 CEST Linus Lüssing wrote:
> > On Sat, Oct 29, 2016 at 12:56:28PM +0200, Jiri Pirko wrote:
> > > >> I strongly believe it is a huge mistake to use sysfs for things like
> > > >> this. This should be done via generic netlink api.
> > > >
> > > >This doesn't change the problem that it is already that way. This patch
> > > >only adds the list of available files to the README.
> > >
> > > Sure. Just found out you did it like that. Therefore I commented. I
> > > suggest to rework the api to use genl entirely.
> >
> > Hi Jiri,
> >
> > Thanks for sharing your thoughts!
> >
> > Could you explain a bit more on which disadvantages you see in
> > the usage of sysfs here?
>
> Linus is asking because of following patch:
> https://patchwork.open-mesh.org/patch/17340/
The next patch with a similar problem would be
https://patchwork.open-mesh.org/patch/17372/. It is rather important that you
are discussing this with Linus Luessing and Marek Lindner.
Kind regards,
Sven
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply
* Re: [PATCH 08/32] aio: replace kiocb_set_cancel_fn with a cancel_kiocb file operation
From: Al Viro @ 2018-05-20 5:27 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Avi Kivity, linux-aio, linux-fsdevel, netdev, linux-api,
linux-kernel
In-Reply-To: <20180515194833.6906-9-hch@lst.de>
On Tue, May 15, 2018 at 09:48:09PM +0200, Christoph Hellwig wrote:
> case -EIOCBQUEUED:
> + if (req->ki_filp->f_op->cancel_kiocb) {
> + struct aio_kiocb *iocb =
> + container_of(req, struct aio_kiocb, rw);
> + struct kioctx *ctx = iocb->ki_ctx;
> + unsigned long flags;
> +
> + spin_lock_irqsave(&ctx->ctx_lock, flags);
> + list_add_tail(&iocb->ki_list, &ctx->active_reqs);
Use after free - that list insertion used to be done by drivers and doing
so before any ->ki_complete() calls might've happened used to be their
responsibility. Now you've taken that to the point after ->read_iter()
(or ->write_iter()) return, so there's no way in hell to guarantee it's
not been completed (and freed) by that point.
Incidentally, none of the callers gives a damn about the difference between
0 and -EIOCBQUEUED now, so aio_rw_ret() might as well had been made void...
--
To unsubscribe, send a message with 'unsubscribe linux-aio' in
the body to majordomo@kvack.org. For more info on Linux AIO,
see: http://www.kvack.org/aio/
Don't email: <a href=mailto:"aart@kvack.org">aart@kvack.org</a>
^ permalink raw reply
* Re: [PATCH 10/32] aio: implement IOCB_CMD_POLL
From: Al Viro @ 2018-05-20 5:32 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Avi Kivity, linux-aio, linux-fsdevel, netdev, linux-api,
linux-kernel
In-Reply-To: <20180515194833.6906-11-hch@lst.de>
On Tue, May 15, 2018 at 09:48:11PM +0200, Christoph Hellwig wrote:
> +static ssize_t aio_poll(struct aio_kiocb *aiocb, struct iocb *iocb)
> +{
> + struct kioctx *ctx = aiocb->ki_ctx;
> + struct poll_iocb *req = &aiocb->poll;
> + unsigned long flags;
> + __poll_t mask;
> +
> + /* reject any unknown events outside the normal event mask. */
> + if ((u16)iocb->aio_buf != iocb->aio_buf)
> + return -EINVAL;
> + /* reject fields that are not defined for poll */
> + if (iocb->aio_offset || iocb->aio_nbytes || iocb->aio_rw_flags)
> + return -EINVAL;
> +
> + req->events = demangle_poll(iocb->aio_buf) | POLLERR | POLLHUP;
> + req->file = fget(iocb->aio_fildes);
> + if (unlikely(!req->file))
> + return -EBADF;
> + if (!file_has_poll_mask(req->file))
> + goto out_fail;
> +
> + req->head = req->file->f_op->get_poll_head(req->file, req->events);
> + if (!req->head)
> + goto out_fail;
> + if (IS_ERR(req->head)) {
> + mask = EPOLLERR;
> + goto done;
> + }
> +
> + init_waitqueue_func_entry(&req->wait, aio_poll_wake);
> + aiocb->ki_cancel = aio_poll_cancel;
> +
> + spin_lock_irqsave(&ctx->ctx_lock, flags);
> + list_add_tail(&aiocb->ki_list, &ctx->delayed_cancel_reqs);
> + spin_unlock(&ctx->ctx_lock);
... and io_cancel(2) comes, finds it and inhume^Wcompletes it, leaving us to...
> + spin_lock(&req->head->lock);
... get buggered on attempt to dereference a pointer fetched from freed and
reused object.
--
To unsubscribe, send a message with 'unsubscribe linux-aio' in
the body to majordomo@kvack.org. For more info on Linux AIO,
see: http://www.kvack.org/aio/
Don't email: <a href=mailto:"aart@kvack.org">aart@kvack.org</a>
^ permalink raw reply
* Re: [PATCH 03/17] batman-adv: Add network_coding and mcast sysfs files to README
From: Jiri Pirko @ 2018-05-20 6:19 UTC (permalink / raw)
To: Linus Lüssing
Cc: netdev-u79uwXL29TY76Z2rM5mHXA,
The list for a Better Approach To Mobile Ad-hoc Networking,
davem-fT/PcQaiUtIeIZ0/mPfg9Q
In-Reply-To: <20180327154307.GA2052@otheros>
Tue, Mar 27, 2018 at 05:43:08PM CEST, linus.luessing-djzkFPsfvsizQB+pC5nmwQ@public.gmane.org wrote:
>On Sat, Oct 29, 2016 at 12:56:28PM +0200, Jiri Pirko wrote:
>> >> I strongly believe it is a huge mistake to use sysfs for things like
>> >> this. This should be done via generic netlink api.
>> >
>> >This doesn't change the problem that it is already that way. This patch
>> >only adds the list of available files to the README.
>>
>> Sure. Just found out you did it like that. Therefore I commented. I
>> suggest to rework the api to use genl entirely.
>
>Hi Jiri,
>
>Thanks for sharing your thoughts!
>
>Could you explain a bit more on which disadvantages you see in
>the usage of sysfs here?
There are 2 major disadvantages.
1) You don't have any events on a change. An app has to poll in order to
know what changed in kernel. Netlink handles this by sending
multicast messages on a specific socket while whoever is interested
gets the messages.
2) In sysfs, everything is string. There are even mixed values like
"1 (means something)". There are no well defined values. Every driver
can expose same things differently. In Netlink, you have well-defined
attributes, with typed values. You can pass multiple attributes for
the same value if needed.
In general, usage of sysfs in netdev subsystem is frowned upon. I would
suggest to convert your iface to Generic Netlink API and let the
existing sysfs API to rot.
>
>Regards, Linus
^ permalink raw reply
* Re: [PATCH 06/14] net: sched: implement reference counted action release
From: Jiri Pirko @ 2018-05-20 6:22 UTC (permalink / raw)
To: Marcelo Ricardo Leitner
Cc: Vlad Buslov, netdev, davem, jhs, xiyou.wangcong, pablo, kadlec,
fw, ast, daniel, edumazet, keescook, linux-kernel,
netfilter-devel, coreteam, kliteyn
In-Reply-To: <20180519214327.GC5488@localhost.localdomain>
Sat, May 19, 2018 at 11:43:27PM CEST, marcelo.leitner@gmail.com wrote:
>On Mon, May 14, 2018 at 05:27:07PM +0300, Vlad Buslov wrote:
>...
>> @@ -1052,6 +1088,36 @@ static int tca_action_flush(struct net *net, struct nlattr *nla,
>> return err;
>> }
>>
>> +static int tcf_action_delete(struct net *net, struct list_head *actions,
>> + struct netlink_ext_ack *extack)
>> +{
>> + int ret;
>
>Reverse christmass tree.. this line should be the last in variable
>declarations.
>
>> + struct tc_action *a, *tmp;
>> + char kind[IFNAMSIZ];
>> + u32 act_index;
>> +
>> + list_for_each_entry_safe(a, tmp, actions, list) {
>> + const struct tc_action_ops *ops = a->ops;
>> +
>> + /* Actions can be deleted concurrently
>> + * so we must save their type and id to search again
>> + * after reference is released.
>> + */
>> + strncpy(kind, a->ops->kind, sizeof(kind) - 1);
>
>This may be problematic. Why strncpy here?
This is not necessary if Vlad is going to hold module referece, ops
cannot disappear.
>
>a->ops->kind is also of size IFNAMSIZ. If a->ops->kind is actually
>IFNAMSIZ-1 long, kind here won't be NULL terminated, as kind is not
>initialized and strncpy won't add the NULL.
>
>> + act_index = a->tcfa_index;
>> +
>> + list_del(&a->list);
>> + if (tcf_action_put(a))
>> + module_put(ops->owner);
>> +
>> + /* now do the delete */
>> + ret = tcf_action_del_1(net, kind, act_index, extack);
>> + if (ret < 0)
>> + return ret;
>> + }
>> + return 0;
>> +}
^ permalink raw reply
* Re: [PATCH bpf-next 3/3] bpf: Add mtu checking to FIB forwarding helper
From: kbuild test robot @ 2018-05-20 6:41 UTC (permalink / raw)
To: David Ahern; +Cc: kbuild-all, netdev, borkmann, ast, davem, David Ahern
In-Reply-To: <20180517160930.25076-4-dsahern@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 949 bytes --]
Hi David,
I love your patch! Yet something to improve:
[auto build test ERROR on bpf-next/master]
url: https://github.com/0day-ci/linux/commits/David-Ahern/bpf-Add-MTU-check-to-fib-lookup-helper/20180520-103417
base: https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git master
config: ia64-allmodconfig (attached as .config)
compiler: ia64-linux-gcc (GCC) 7.2.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=ia64
All errors (new ones prefixed by >>):
net/core/filter.o: In function `bpf_ipv6_fib_lookup':
>> filter.c:(.text+0x12072): undefined reference to `ip6_mtu_from_fib6'
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 49919 bytes --]
^ permalink raw reply
* Re: [PATCH 10/32] aio: implement IOCB_CMD_POLL
From: Al Viro @ 2018-05-20 7:33 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Avi Kivity, linux-aio, linux-fsdevel, netdev, linux-api,
linux-kernel
In-Reply-To: <20180520053219.GZ30522@ZenIV.linux.org.uk>
On Sun, May 20, 2018 at 06:32:25AM +0100, Al Viro wrote:
> > + spin_lock_irqsave(&ctx->ctx_lock, flags);
> > + list_add_tail(&aiocb->ki_list, &ctx->delayed_cancel_reqs);
> > + spin_unlock(&ctx->ctx_lock);
>
> ... and io_cancel(2) comes, finds it and inhume^Wcompletes it, leaving us to...
>
> > + spin_lock(&req->head->lock);
>
> ... get buggered on attempt to dereference a pointer fetched from freed and
> reused object.
FWIW, how painful would it be to pull the following trick:
* insert into wait queue under ->ctx_lock
* have wakeup do schedule_work() with aio_complete() done from that
* have ->ki_cancel() grab queue lock, remove from queue and use
the same schedule_work()
That way you'd get ->ki_cancel() with the same semantics as originally for
everything - "ask politely to finish ASAP", and called in the same locking
environment for everyone - under ->ctx_lock, that is. queue lock nests
inside ->ctx_lock; no magical flags, etc.
The cost is schedule_work() for each async poll-related completion as you
have for fsync. I don't know whether that's too costly or not; it certainly
simplifies the things, but whether it's OK performance-wise...
Comments?
--
To unsubscribe, send a message with 'unsubscribe linux-aio' in
the body to majordomo@kvack.org. For more info on Linux AIO,
see: http://www.kvack.org/aio/
Don't email: <a href=mailto:"aart@kvack.org">aart@kvack.org</a>
^ permalink raw reply
* Wohltätigkeitsspende in Höhe von € 2.000.000,00
From: vicente.ortiz @ 2018-05-20 3:07 UTC (permalink / raw)
To: Recipients
Lieber Freund,
Ich bin Herr Richard Wahl der Mega-Gewinner von $ 533M In Mega Millions Jackpot spende ich an 5 zufällige Personen, wenn Sie diese E-Mail erhalten, dann wurde Ihre E-Mail nach einem Spinball ausgewählt. Ich habe den größten Teil meines Vermögens auf eine Reihe von Wohltätigkeitsorganisationen und Organisationen verteilt. Ich habe mich freiwillig dazu entschieden, Ihnen den Betrag von € 2.000.000,00 EUR zu spenden
eine der ausgewählten 5, um meine Gewinne zu überprüfen, finden Sie auf meiner You Tube Seite unten.
UHR MICH HIER: https://www.youtube.com/watch?v=tne02ExNDrw
Das ist dein Spendencode: [DF00430342018]
Antworten Sie mit dem Spendencode auf diese E-Mail: richardwahlfunds@workmail.com
Ich hoffe, Sie und Ihre Familie glücklich zu machen.
Grüße
Herr Richard Wahl
^ permalink raw reply
* [patch iproute2/net-next 0/2] devlink: add port flavours/number/split_subport
From: Jiri Pirko @ 2018-05-20 8:15 UTC (permalink / raw)
To: netdev
Cc: dsahern, idosch, jakub.kicinski, mlxsw, andrew, vivien.didelot,
f.fainelli, michael.chan, ganeshgr, saeedm, simon.horman,
pieter.jansenvanvuuren, john.hurley, dirk.vandermerwe,
alexander.h.duyck, ogerlitz, vijaya.guvva, satananda.burla,
raghu.vatsavayi, felix.manlunas, gospo, sathya.perla,
vasundhara-v.volam, tariqt, eranbe, jeffrey.t.kirsher, roopa
From: Jiri Pirko <jiri@mellanox.com>
Jiri Pirko (2):
devlink: introduce support for showing port flavours
devlink: introduce support for showing port number and split subport
number
devlink/devlink.c | 26 ++++++++++++++++++++++++++
include/uapi/linux/devlink.h | 14 ++++++++++++++
2 files changed, 40 insertions(+)
--
2.14.3
^ permalink raw reply
* [patch iproute2/net-next 1/2] devlink: introduce support for showing port flavours
From: Jiri Pirko @ 2018-05-20 8:15 UTC (permalink / raw)
To: netdev
Cc: dsahern, idosch, jakub.kicinski, mlxsw, andrew, vivien.didelot,
f.fainelli, michael.chan, ganeshgr, saeedm, simon.horman,
pieter.jansenvanvuuren, john.hurley, dirk.vandermerwe,
alexander.h.duyck, ogerlitz, vijaya.guvva, satananda.burla,
raghu.vatsavayi, felix.manlunas, gospo, sathya.perla,
vasundhara-v.volam, tariqt, eranbe, jeffrey.t.kirsher, roopa
In-Reply-To: <20180520081539.1372-1-jiri@resnulli.us>
From: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
---
devlink/devlink.c | 20 ++++++++++++++++++++
include/uapi/linux/devlink.h | 12 ++++++++++++
2 files changed, 32 insertions(+)
diff --git a/devlink/devlink.c b/devlink/devlink.c
index fa33684cb20a..df2c66dac1c7 100644
--- a/devlink/devlink.c
+++ b/devlink/devlink.c
@@ -1693,6 +1693,20 @@ static const char *port_type_name(uint32_t type)
}
}
+static const char *port_flavour_name(uint16_t flavour)
+{
+ switch (flavour) {
+ case DEVLINK_PORT_FLAVOUR_PHYSICAL:
+ return "physical";
+ case DEVLINK_PORT_FLAVOUR_CPU:
+ return "cpu";
+ case DEVLINK_PORT_FLAVOUR_DSA:
+ return "dsa";
+ default:
+ return "<unknown flavour>";
+ }
+}
+
static void pr_out_port(struct dl *dl, struct nlattr **tb)
{
struct nlattr *pt_attr = tb[DEVLINK_ATTR_PORT_TYPE];
@@ -1717,6 +1731,12 @@ static void pr_out_port(struct dl *dl, struct nlattr **tb)
if (tb[DEVLINK_ATTR_PORT_IBDEV_NAME])
pr_out_str(dl, "ibdev",
mnl_attr_get_str(tb[DEVLINK_ATTR_PORT_IBDEV_NAME]));
+ if (tb[DEVLINK_ATTR_PORT_FLAVOUR]) {
+ uint16_t port_flavour =
+ mnl_attr_get_u16(tb[DEVLINK_ATTR_PORT_FLAVOUR]);
+
+ pr_out_str(dl, "flavour", port_flavour_name(port_flavour));
+ }
if (tb[DEVLINK_ATTR_PORT_SPLIT_GROUP])
pr_out_uint(dl, "split_group",
mnl_attr_get_u32(tb[DEVLINK_ATTR_PORT_SPLIT_GROUP]));
diff --git a/include/uapi/linux/devlink.h b/include/uapi/linux/devlink.h
index 9f17286ec89f..23a3af6284b4 100644
--- a/include/uapi/linux/devlink.h
+++ b/include/uapi/linux/devlink.h
@@ -132,6 +132,16 @@ enum devlink_eswitch_encap_mode {
DEVLINK_ESWITCH_ENCAP_MODE_BASIC,
};
+enum devlink_port_flavour {
+ DEVLINK_PORT_FLAVOUR_PHYSICAL, /* Any kind of a port physically
+ * facing the user.
+ */
+ DEVLINK_PORT_FLAVOUR_CPU, /* CPU port */
+ DEVLINK_PORT_FLAVOUR_DSA, /* Distributed switch architecture
+ * interconnect port.
+ */
+};
+
enum devlink_attr {
/* don't change the order or add anything between, this is ABI! */
DEVLINK_ATTR_UNSPEC,
@@ -224,6 +234,8 @@ enum devlink_attr {
DEVLINK_ATTR_DPIPE_TABLE_RESOURCE_ID, /* u64 */
DEVLINK_ATTR_DPIPE_TABLE_RESOURCE_UNITS,/* u64 */
+ DEVLINK_ATTR_PORT_FLAVOUR, /* u16 */
+
/* add new attributes above here, update the policy in devlink.c */
__DEVLINK_ATTR_MAX,
--
2.14.3
^ permalink raw reply related
* [patch iproute2/net-next 2/2] devlink: introduce support for showing port number and split subport number
From: Jiri Pirko @ 2018-05-20 8:15 UTC (permalink / raw)
To: netdev
Cc: dsahern, idosch, jakub.kicinski, mlxsw, andrew, vivien.didelot,
f.fainelli, michael.chan, ganeshgr, saeedm, simon.horman,
pieter.jansenvanvuuren, john.hurley, dirk.vandermerwe,
alexander.h.duyck, ogerlitz, vijaya.guvva, satananda.burla,
raghu.vatsavayi, felix.manlunas, gospo, sathya.perla,
vasundhara-v.volam, tariqt, eranbe, jeffrey.t.kirsher, roopa
In-Reply-To: <20180520081539.1372-1-jiri@resnulli.us>
From: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
---
devlink/devlink.c | 6 ++++++
include/uapi/linux/devlink.h | 2 ++
2 files changed, 8 insertions(+)
diff --git a/devlink/devlink.c b/devlink/devlink.c
index df2c66dac1c7..b0ae17767dab 100644
--- a/devlink/devlink.c
+++ b/devlink/devlink.c
@@ -1737,9 +1737,15 @@ static void pr_out_port(struct dl *dl, struct nlattr **tb)
pr_out_str(dl, "flavour", port_flavour_name(port_flavour));
}
+ if (tb[DEVLINK_ATTR_PORT_NUMBER])
+ pr_out_uint(dl, "number",
+ mnl_attr_get_u32(tb[DEVLINK_ATTR_PORT_NUMBER]));
if (tb[DEVLINK_ATTR_PORT_SPLIT_GROUP])
pr_out_uint(dl, "split_group",
mnl_attr_get_u32(tb[DEVLINK_ATTR_PORT_SPLIT_GROUP]));
+ if (tb[DEVLINK_ATTR_PORT_SPLIT_SUBPORT_NUMBER])
+ pr_out_uint(dl, "subport",
+ mnl_attr_get_u32(tb[DEVLINK_ATTR_PORT_SPLIT_SUBPORT_NUMBER]));
pr_out_port_handle_end(dl);
}
diff --git a/include/uapi/linux/devlink.h b/include/uapi/linux/devlink.h
index 23a3af6284b4..493f71fef7ee 100644
--- a/include/uapi/linux/devlink.h
+++ b/include/uapi/linux/devlink.h
@@ -235,6 +235,8 @@ enum devlink_attr {
DEVLINK_ATTR_DPIPE_TABLE_RESOURCE_UNITS,/* u64 */
DEVLINK_ATTR_PORT_FLAVOUR, /* u16 */
+ DEVLINK_ATTR_PORT_NUMBER, /* u32 */
+ DEVLINK_ATTR_PORT_SPLIT_SUBPORT_NUMBER, /* u32 */
/* add new attributes above here, update the policy in devlink.c */
--
2.14.3
^ permalink raw reply related
* Re: INFO: rcu detected stall in is_bpf_text_address
From: Xin Long @ 2018-05-20 8:26 UTC (permalink / raw)
To: Eric Dumazet, Marcelo Ricardo Leitner
Cc: syzbot, ast, Daniel Borkmann, LKML, network dev, syzkaller-bugs
In-Reply-To: <4b65142a-cf3b-05d7-d66b-018ff8da7ccc@gmail.com>
On Sat, May 19, 2018 at 11:57 PM, Eric Dumazet <eric.dumazet@gmail.com> wrote:
> SCTP experts, please take a look.
>
> On 05/19/2018 08:55 AM, syzbot wrote:
>> Hello,
>>
>> syzbot found the following crash on:
>>
>> HEAD commit: 73fcb1a370c7 Merge branch 'akpm' (patches from Andrew)
>> git tree: upstream
>> console output: https://syzkaller.appspot.com/x/log.txt?x=1462ec0f800000
>> kernel config: https://syzkaller.appspot.com/x/.config?x=f3b4e30da84ec1ed
>> dashboard link: https://syzkaller.appspot.com/bug?extid=3dcd59a1f907245f891f
>> compiler: gcc (GCC) 8.0.1 20180413 (experimental)
>> syzkaller repro:https://syzkaller.appspot.com/x/repro.syz?x=1079cf8f800000
Thank you.
The Reproducer is more than helpful.
setsockopt$inet_sctp6_SCTP_RTOINFO(r0, 0x84, 0x0,
&(0x7f0000000140)={0x0, 0x6, 0x7, 0x4}, 0x10)
It set rto_min=6 and rto_max=7, these are too small values.
t3_rtx timer works fine with it. But hb_timer will get stuck there, as
in its timer handler it starts this timer again with this value, then
it goes to the timer handler again...
HB has to repeat this and the hb timer's expire may also have to use
'trans->rto >> 1 ...' stuff. But we can limit the RTO's min value, like
HZ/20, which is 'Try again later.' number used when sock lock is
owned by others in all timer handlers.
^ permalink raw reply
* [PATCH net] sctp: fix the issue that flags are ignored when using kernel_connect
From: Xin Long @ 2018-05-20 8:39 UTC (permalink / raw)
To: network dev, linux-sctp
Cc: davem, Marcelo Ricardo Leitner, Neil Horman, mkubecek
Now sctp uses inet_dgram_connect as its proto_ops .connect, and the flags
param can't be passed into its proto .connect where this flags is really
needed.
sctp works around it by getting flags from socket file in __sctp_connect.
It works for connecting from userspace, as inherently the user sock has
socket file and it passes f_flags as the flags param into the proto_ops
.connect.
However, the sock created by sock_create_kern doesn't have a socket file,
and it passes the flags (like O_NONBLOCK) by using the flags param in
kernel_connect, which calls proto_ops .connect later.
So to fix it, this patch defines a new proto_ops .connect for sctp,
sctp_inet_connect, which calls __sctp_connect() directly with this
flags param. After this, the sctp's proto .connect can be removed.
Note that sctp_inet_connect doesn't need to do some checks that are not
needed for sctp, which makes thing better than with inet_dgram_connect.
Suggested-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
include/net/sctp/sctp.h | 2 ++
net/sctp/ipv6.c | 2 +-
net/sctp/protocol.c | 2 +-
net/sctp/socket.c | 51 +++++++++++++++++++++++++++++++++----------------
4 files changed, 39 insertions(+), 18 deletions(-)
diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h
index 28b996d..35498e6 100644
--- a/include/net/sctp/sctp.h
+++ b/include/net/sctp/sctp.h
@@ -103,6 +103,8 @@ void sctp_addr_wq_mgmt(struct net *, struct sctp_sockaddr_entry *, int);
/*
* sctp/socket.c
*/
+int sctp_inet_connect(struct socket *sock, struct sockaddr *uaddr,
+ int addr_len, int flags);
int sctp_backlog_rcv(struct sock *sk, struct sk_buff *skb);
int sctp_inet_listen(struct socket *sock, int backlog);
void sctp_write_space(struct sock *sk);
diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
index 4224711..0cd2e76 100644
--- a/net/sctp/ipv6.c
+++ b/net/sctp/ipv6.c
@@ -1006,7 +1006,7 @@ static const struct proto_ops inet6_seqpacket_ops = {
.owner = THIS_MODULE,
.release = inet6_release,
.bind = inet6_bind,
- .connect = inet_dgram_connect,
+ .connect = sctp_inet_connect,
.socketpair = sock_no_socketpair,
.accept = inet_accept,
.getname = sctp_getname,
diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
index d685f84..6bf0a99 100644
--- a/net/sctp/protocol.c
+++ b/net/sctp/protocol.c
@@ -1012,7 +1012,7 @@ static const struct proto_ops inet_seqpacket_ops = {
.owner = THIS_MODULE,
.release = inet_release, /* Needs to be wrapped... */
.bind = inet_bind,
- .connect = inet_dgram_connect,
+ .connect = sctp_inet_connect,
.socketpair = sock_no_socketpair,
.accept = inet_accept,
.getname = inet_getname, /* Semantics are different. */
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index 80835ac..ae7e7c6 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -1086,7 +1086,7 @@ static int sctp_setsockopt_bindx(struct sock *sk,
*/
static int __sctp_connect(struct sock *sk,
struct sockaddr *kaddrs,
- int addrs_size,
+ int addrs_size, int flags,
sctp_assoc_t *assoc_id)
{
struct net *net = sock_net(sk);
@@ -1104,7 +1104,6 @@ static int __sctp_connect(struct sock *sk,
union sctp_addr *sa_addr = NULL;
void *addr_buf;
unsigned short port;
- unsigned int f_flags = 0;
sp = sctp_sk(sk);
ep = sp->ep;
@@ -1254,13 +1253,7 @@ static int __sctp_connect(struct sock *sk,
sp->pf->to_sk_daddr(sa_addr, sk);
sk->sk_err = 0;
- /* in-kernel sockets don't generally have a file allocated to them
- * if all they do is call sock_create_kern().
- */
- if (sk->sk_socket->file)
- f_flags = sk->sk_socket->file->f_flags;
-
- timeo = sock_sndtimeo(sk, f_flags & O_NONBLOCK);
+ timeo = sock_sndtimeo(sk, flags & O_NONBLOCK);
if (assoc_id)
*assoc_id = asoc->assoc_id;
@@ -1348,7 +1341,7 @@ static int __sctp_setsockopt_connectx(struct sock *sk,
sctp_assoc_t *assoc_id)
{
struct sockaddr *kaddrs;
- int err = 0;
+ int err = 0, flags = 0;
pr_debug("%s: sk:%p addrs:%p addrs_size:%d\n",
__func__, sk, addrs, addrs_size);
@@ -1367,7 +1360,13 @@ static int __sctp_setsockopt_connectx(struct sock *sk,
if (err)
goto out_free;
- err = __sctp_connect(sk, kaddrs, addrs_size, assoc_id);
+ /* in-kernel sockets don't generally have a file allocated to them
+ * if all they do is call sock_create_kern().
+ */
+ if (sk->sk_socket->file)
+ flags = sk->sk_socket->file->f_flags;
+
+ err = __sctp_connect(sk, kaddrs, addrs_size, flags, assoc_id);
out_free:
kvfree(kaddrs);
@@ -4397,16 +4396,26 @@ static int sctp_setsockopt(struct sock *sk, int level, int optname,
* len: the size of the address.
*/
static int sctp_connect(struct sock *sk, struct sockaddr *addr,
- int addr_len)
+ int addr_len, int flags)
{
- int err = 0;
+ struct inet_sock *inet = inet_sk(sk);
struct sctp_af *af;
+ int err = 0;
lock_sock(sk);
pr_debug("%s: sk:%p, sockaddr:%p, addr_len:%d\n", __func__, sk,
addr, addr_len);
+ /* We may need to bind the socket. */
+ if (!inet->inet_num) {
+ if (sk->sk_prot->get_port(sk, 0)) {
+ release_sock(sk);
+ return -EAGAIN;
+ }
+ inet->inet_sport = htons(inet->inet_num);
+ }
+
/* Validate addr_len before calling common connect/connectx routine. */
af = sctp_get_af_specific(addr->sa_family);
if (!af || addr_len < af->sockaddr_len) {
@@ -4415,13 +4424,25 @@ static int sctp_connect(struct sock *sk, struct sockaddr *addr,
/* Pass correct addr len to common routine (so it knows there
* is only one address being passed.
*/
- err = __sctp_connect(sk, addr, af->sockaddr_len, NULL);
+ err = __sctp_connect(sk, addr, af->sockaddr_len, flags, NULL);
}
release_sock(sk);
return err;
}
+int sctp_inet_connect(struct socket *sock, struct sockaddr *uaddr,
+ int addr_len, int flags)
+{
+ if (addr_len < sizeof(uaddr->sa_family))
+ return -EINVAL;
+
+ if (uaddr->sa_family == AF_UNSPEC)
+ return -EOPNOTSUPP;
+
+ return sctp_connect(sock->sk, uaddr, addr_len, flags);
+}
+
/* FIXME: Write comments. */
static int sctp_disconnect(struct sock *sk, int flags)
{
@@ -8724,7 +8745,6 @@ struct proto sctp_prot = {
.name = "SCTP",
.owner = THIS_MODULE,
.close = sctp_close,
- .connect = sctp_connect,
.disconnect = sctp_disconnect,
.accept = sctp_accept,
.ioctl = sctp_ioctl,
@@ -8767,7 +8787,6 @@ struct proto sctpv6_prot = {
.name = "SCTPv6",
.owner = THIS_MODULE,
.close = sctp_close,
- .connect = sctp_connect,
.disconnect = sctp_disconnect,
.accept = sctp_accept,
.ioctl = sctp_ioctl,
--
2.1.0
^ permalink raw reply related
* Re: [PATCH 02/14] net: sched: change type of reference and bind counters
From: Vlad Buslov @ 2018-05-20 10:55 UTC (permalink / raw)
To: Marcelo Ricardo Leitner
Cc: netdev, davem, jhs, xiyou.wangcong, jiri, pablo, kadlec, fw, ast,
daniel, edumazet, keescook, linux-kernel, netfilter-devel,
coreteam, kliteyn
In-Reply-To: <20180519210442.GA5488@localhost.localdomain>
On Sat 19 May 2018 at 21:04, Marcelo Ricardo Leitner <marcelo.leitner@gmail.com> wrote:
> On Mon, May 14, 2018 at 05:27:03PM +0300, Vlad Buslov wrote:
>> Change type of action reference counter to refcount_t.
>>
>> Change type of action bind counter to atomic_t.
>> This type is used to allow decrementing bind counter without testing
>> for 0 result.
>
> ... and in what does not testing for 0 result helps?
>
> Marcelo
Atomic operations don't WARN in this case.
^ permalink raw reply
* Re: [PATCH 06/14] net: sched: implement reference counted action release
From: Vlad Buslov @ 2018-05-20 10:59 UTC (permalink / raw)
To: Jiri Pirko
Cc: Marcelo Ricardo Leitner, netdev, davem, jhs, xiyou.wangcong,
pablo, kadlec, fw, ast, daniel, edumazet, keescook, linux-kernel,
netfilter-devel, coreteam, kliteyn
In-Reply-To: <20180520062242.GB2255@nanopsycho.orion>
On Sun 20 May 2018 at 06:22, Jiri Pirko <jiri@resnulli.us> wrote:
> Sat, May 19, 2018 at 11:43:27PM CEST, marcelo.leitner@gmail.com wrote:
>>On Mon, May 14, 2018 at 05:27:07PM +0300, Vlad Buslov wrote:
>>...
>>> @@ -1052,6 +1088,36 @@ static int tca_action_flush(struct net *net, struct nlattr *nla,
>>> return err;
>>> }
>>>
>>> +static int tcf_action_delete(struct net *net, struct list_head *actions,
>>> + struct netlink_ext_ack *extack)
>>> +{
>>> + int ret;
>>
>>Reverse christmass tree.. this line should be the last in variable
>>declarations.
>>
>>> + struct tc_action *a, *tmp;
>>> + char kind[IFNAMSIZ];
>>> + u32 act_index;
>>> +
>>> + list_for_each_entry_safe(a, tmp, actions, list) {
>>> + const struct tc_action_ops *ops = a->ops;
>>> +
>>> + /* Actions can be deleted concurrently
>>> + * so we must save their type and id to search again
>>> + * after reference is released.
>>> + */
>>> + strncpy(kind, a->ops->kind, sizeof(kind) - 1);
>>
>>This may be problematic. Why strncpy here?
>
> This is not necessary if Vlad is going to hold module referece, ops
> cannot disappear.
Yes, I've already refactored this code to reuse ops.
>
>
>>
>>a->ops->kind is also of size IFNAMSIZ. If a->ops->kind is actually
>>IFNAMSIZ-1 long, kind here won't be NULL terminated, as kind is not
>>initialized and strncpy won't add the NULL.
>>
>>> + act_index = a->tcfa_index;
>>> +
>>> + list_del(&a->list);
>>> + if (tcf_action_put(a))
>>> + module_put(ops->owner);
>>> +
>>> + /* now do the delete */
>>> + ret = tcf_action_del_1(net, kind, act_index, extack);
>>> + if (ret < 0)
>>> + return ret;
>>> + }
>>> + return 0;
>>> +}
^ permalink raw reply
* [PATCH net-next v1] netfilter: provide input interface for route lookup for rpfilter
From: Vincent Bernat @ 2018-05-20 11:03 UTC (permalink / raw)
To: Pablo Neira Ayuso, Jozsef Kadlecsik, Florian Westphal,
David S. Miller, netfilter-devel, netdev
Cc: Vincent Bernat
In commit 47b7e7f82802, this bit was removed at the same time the
RT6_LOOKUP_F_IFACE flag was removed. However, it is needed when
link-local addresses are used, which is a very common case: when
packets are routed, neighbor solicitations are done using link-local
addresses. For example, the following neighbor solicitation is not
matched by "-m rpfilter":
IP6 fe80::5254:33ff:fe00:1 > ff02::1:ff00:3: ICMP6, neighbor
solicitation, who has 2001:db8::5254:33ff:fe00:3, length 32
Commit 47b7e7f82802 doesn't quite explain why we shouldn't use
RT6_LOOKUP_F_IFACE in the rpfilter case. I suppose the interface check
later in the function would make it redundant. However, the remaining
of the routing code is using RT6_LOOKUP_F_IFACE when there is no
source address (which matches rpfilter's case with a non-unicast
destination, like with neighbor solicitation).
Signed-off-by: Vincent Bernat <vincent@bernat.im>
Fixes: 47b7e7f82802 ("netfilter: don't set F_IFACE on ipv6 fib lookups")
---
net/ipv6/netfilter/ip6t_rpfilter.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/net/ipv6/netfilter/ip6t_rpfilter.c b/net/ipv6/netfilter/ip6t_rpfilter.c
index d12f511929f5..0fe61ede77c6 100644
--- a/net/ipv6/netfilter/ip6t_rpfilter.c
+++ b/net/ipv6/netfilter/ip6t_rpfilter.c
@@ -48,6 +48,8 @@ static bool rpfilter_lookup_reverse6(struct net *net, const struct sk_buff *skb,
}
fl6.flowi6_mark = flags & XT_RPFILTER_VALID_MARK ? skb->mark : 0;
+ if ((flags & XT_RPFILTER_LOOSE) == 0)
+ fl6.flowi6_oif = dev->ifindex;
rt = (void *)ip6_route_lookup(net, &fl6, skb, lookup_flags);
if (rt->dst.error)
--
2.17.0
^ permalink raw reply related
* [PATCH] bpf: fix mem leak in error path of lwt bpf setup
From: Mathieu Xhonneux @ 2018-05-20 13:08 UTC (permalink / raw)
To: netdev; +Cc: daniel, alexei.starovoitov
In bpf_parse_prog, if bpf_prog_get_type fails, the function is
immediately terminated without freeing the previously allocated
prog->name.
This patch adds a kfree before the return.
Signed-off-by: Mathieu Xhonneux <m.xhonneux@gmail.com>
---
net/core/lwt_bpf.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/net/core/lwt_bpf.c b/net/core/lwt_bpf.c
index e7e626fb87bb..e142a7a32e46 100644
--- a/net/core/lwt_bpf.c
+++ b/net/core/lwt_bpf.c
@@ -223,8 +223,10 @@ static int bpf_parse_prog(struct nlattr *attr, struct bpf_lwt_prog *prog,
fd = nla_get_u32(tb[LWT_BPF_PROG_FD]);
p = bpf_prog_get_type(fd, type);
- if (IS_ERR(p))
+ if (IS_ERR(p)) {
+ kfree(prog->name);
return PTR_ERR(p);
+ }
prog->prog = p;
--
2.16.1
^ permalink raw reply related
* Re: [PATCH bpf-next 3/3] bpf: Add mtu checking to FIB forwarding helper
From: kbuild test robot @ 2018-05-20 11:14 UTC (permalink / raw)
To: David Ahern; +Cc: kbuild-all, netdev, borkmann, ast, davem, David Ahern
In-Reply-To: <20180517160930.25076-4-dsahern@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 4196 bytes --]
Hi David,
I love your patch! Yet something to improve:
[auto build test ERROR on bpf-next/master]
url: https://github.com/0day-ci/linux/commits/David-Ahern/bpf-Add-MTU-check-to-fib-lookup-helper/20180520-103417
base: https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git master
config: x86_64-randconfig-ws0-05200859 (attached as .config)
compiler: gcc-7 (Debian 7.3.0-16) 7.3.0
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64
All errors (new ones prefixed by >>):
net/core/filter.o: In function `bpf_ipv6_fib_lookup':
>> net/core/filter.c:4259: undefined reference to `ip6_mtu_from_fib6'
vim +4259 net/core/filter.c
4182
4183 #if IS_ENABLED(CONFIG_IPV6)
4184 static int bpf_ipv6_fib_lookup(struct net *net, struct bpf_fib_lookup *params,
4185 u32 flags)
4186 {
4187 struct in6_addr *src = (struct in6_addr *) params->ipv6_src;
4188 struct in6_addr *dst = (struct in6_addr *) params->ipv6_dst;
4189 struct neighbour *neigh;
4190 struct net_device *dev;
4191 struct inet6_dev *idev;
4192 struct fib6_info *f6i;
4193 struct flowi6 fl6;
4194 int strict = 0;
4195 int oif;
4196 u32 mtu;
4197
4198 /* link local addresses are never forwarded */
4199 if (rt6_need_strict(dst) || rt6_need_strict(src))
4200 return 0;
4201
4202 dev = dev_get_by_index_rcu(net, params->ifindex);
4203 if (unlikely(!dev))
4204 return -ENODEV;
4205
4206 idev = __in6_dev_get_safely(dev);
4207 if (unlikely(!idev || !net->ipv6.devconf_all->forwarding))
4208 return 0;
4209
4210 if (flags & BPF_FIB_LOOKUP_OUTPUT) {
4211 fl6.flowi6_iif = 1;
4212 oif = fl6.flowi6_oif = params->ifindex;
4213 } else {
4214 oif = fl6.flowi6_iif = params->ifindex;
4215 fl6.flowi6_oif = 0;
4216 strict = RT6_LOOKUP_F_HAS_SADDR;
4217 }
4218 fl6.flowlabel = params->flowlabel;
4219 fl6.flowi6_scope = 0;
4220 fl6.flowi6_flags = 0;
4221 fl6.mp_hash = 0;
4222
4223 fl6.flowi6_proto = params->l4_protocol;
4224 fl6.daddr = *dst;
4225 fl6.saddr = *src;
4226 fl6.fl6_sport = params->sport;
4227 fl6.fl6_dport = params->dport;
4228
4229 if (flags & BPF_FIB_LOOKUP_DIRECT) {
4230 u32 tbid = l3mdev_fib_table_rcu(dev) ? : RT_TABLE_MAIN;
4231 struct fib6_table *tb;
4232
4233 tb = ipv6_stub->fib6_get_table(net, tbid);
4234 if (unlikely(!tb))
4235 return 0;
4236
4237 f6i = ipv6_stub->fib6_table_lookup(net, tb, oif, &fl6, strict);
4238 } else {
4239 fl6.flowi6_mark = 0;
4240 fl6.flowi6_secid = 0;
4241 fl6.flowi6_tun_key.tun_id = 0;
4242 fl6.flowi6_uid = sock_net_uid(net, NULL);
4243
4244 f6i = ipv6_stub->fib6_lookup(net, oif, &fl6, strict);
4245 }
4246
4247 if (unlikely(IS_ERR_OR_NULL(f6i) || f6i == net->ipv6.fib6_null_entry))
4248 return 0;
4249
4250 if (unlikely(f6i->fib6_flags & RTF_REJECT ||
4251 f6i->fib6_type != RTN_UNICAST))
4252 return 0;
4253
4254 if (f6i->fib6_nsiblings && fl6.flowi6_oif == 0)
4255 f6i = ipv6_stub->fib6_multipath_select(net, f6i, &fl6,
4256 fl6.flowi6_oif, NULL,
4257 strict);
4258
> 4259 mtu = ip6_mtu_from_fib6(f6i, dst, src);
4260 if (params->tot_len > mtu)
4261 return 0;
4262
4263 if (f6i->fib6_nh.nh_lwtstate)
4264 return 0;
4265
4266 if (f6i->fib6_flags & RTF_GATEWAY)
4267 *dst = f6i->fib6_nh.nh_gw;
4268
4269 dev = f6i->fib6_nh.nh_dev;
4270 params->rt_metric = f6i->fib6_metric;
4271
4272 /* xdp and cls_bpf programs are run in RCU-bh so rcu_read_lock_bh is
4273 * not needed here. Can not use __ipv6_neigh_lookup_noref here
4274 * because we need to get nd_tbl via the stub
4275 */
4276 neigh = ___neigh_lookup_noref(ipv6_stub->nd_tbl, neigh_key_eq128,
4277 ndisc_hashfn, dst, dev);
4278 if (neigh)
4279 return bpf_fib_set_fwd_params(params, neigh, dev);
4280
4281 return 0;
4282 }
4283 #endif
4284
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 33614 bytes --]
^ permalink raw reply
* Re: [PATCH bpf-next v6 5/6] ipv6: sr: Add seg6local action End.BPF
From: Mathieu Xhonneux @ 2018-05-20 11:21 UTC (permalink / raw)
To: Daniel Borkmann; +Cc: netdev, David Lebrun, Alexei Starovoitov
In-Reply-To: <d6906397-69cd-a13e-a3bb-b30dcddd6163@iogearbox.net>
2018-05-18 21:24 GMT+01:00 Daniel Borkmann <daniel@iogearbox.net>:
>> +#define MAX_PROG_NAME 256
>> +static const struct nla_policy bpf_prog_policy[LWT_BPF_PROG_MAX + 1] = {
>> + [LWT_BPF_PROG_FD] = { .type = NLA_U32, },
>
> From UAPI point of view, I wouldn't name it LWT_BPF_PROG_FD but rather something like
> LWT_BPF_PROG for example. That way, the setup can contain the fd number, but on the
> dump you can put the prog->aux->id in there so that prog lookup can be done again.
Good idea.
>> + [LWT_BPF_PROG_NAME] = { .type = NLA_NUL_STRING,
>> + .len = MAX_PROG_NAME },
>> +};
>> +
>> +static int parse_nla_bpf(struct nlattr **attrs, struct seg6_local_lwt *slwt)
>> +{
>> + struct nlattr *tb[LWT_BPF_PROG_MAX + 1];
>> + struct bpf_prog *p;
>> + int ret;
>> + u32 fd;
>> +
>> + ret = nla_parse_nested(tb, LWT_BPF_PROG_MAX, attrs[SEG6_LOCAL_BPF],
>> + bpf_prog_policy, NULL);
>> + if (ret < 0)
>> + return ret;
>> +
>> + if (!tb[LWT_BPF_PROG_FD] || !tb[LWT_BPF_PROG_NAME])
>> + return -EINVAL;
>> +
>> + slwt->bpf.name = nla_memdup(tb[LWT_BPF_PROG_NAME], GFP_KERNEL);
>> + if (!slwt->bpf.name)
>> + return -ENOMEM;
>> +
>> + fd = nla_get_u32(tb[LWT_BPF_PROG_FD]);
>> + p = bpf_prog_get_type(fd, BPF_PROG_TYPE_LWT_SEG6LOCAL);
>> + if (IS_ERR(p))
>> + return PTR_ERR(p);
>
> Here in the above error path is definitely a bug in that you don't free the
> prior allocated slwt->bpf.name from nla_memdup().
Indeed, I took this part from the lwt bpf infrastructure. I sent a
patch to fix it there too.
> Also when you destroy the struct seg6_local_lwt object, what I'm not getting
> is where you drop the prog reference again and free slwt->bpf.name there?
I totally missed this. Sending a v7 with all of this fixed.
Thanks for your comments !
^ permalink raw reply
* [PATCH bpf-next v7 0/6] ipv6: sr: introduce seg6local End.BPF action
From: Mathieu Xhonneux @ 2018-05-20 13:58 UTC (permalink / raw)
To: netdev; +Cc: daniel, dlebrun, alexei.starovoitov
As of Linux 4.14, it is possible to define advanced local processing for
IPv6 packets with a Segment Routing Header through the seg6local LWT
infrastructure. This LWT implements the network programming principles
defined in the IETF “SRv6 Network Programming” draft.
The implemented operations are generic, and it would be very interesting to
be able to implement user-specific seg6local actions, without having to
modify the kernel directly. To do so, this patchset adds an End.BPF action
to seg6local, powered by some specific Segment Routing-related helpers,
which provide SR functionalities that can be applied on the packet. This
BPF hook would then allow to implement specific actions at native kernel
speed such as OAM features, advanced SR SDN policies, SRv6 actions like
Segment Routing Header (SRH) encapsulation depending on the content of
the packet, etc.
This patchset is divided in 6 patches, whose main features are :
- A new seg6local action End.BPF with the corresponding new BPF program
type BPF_PROG_TYPE_LWT_SEG6LOCAL. Such attached BPF program can be
passed to the LWT seg6local through netlink, the same way as the LWT
BPF hook operates.
- 3 new BPF helpers for the seg6local BPF hook, allowing to edit/grow/
shrink a SRH and apply on a packet some of the generic SRv6 actions.
- 1 new BPF helper for the LWT BPF IN hook, allowing to add a SRH through
encapsulation (via IPv6 encapsulation or inlining if the packet contains
already an IPv6 header).
As this patchset adds a new LWT BPF hook, I took into account the result of
the discussions when the LWT BPF infrastructure got merged. Hence, the
seg6local BPF hook doesn’t allow write access to skb->data directly, only
the SRH can be modified through specific helpers, which ensures that the
integrity of the packet is maintained.
More details are available in the related patches messages.
The performances of this BPF hook have been assessed with the BPF JIT
enabled on an Intel Xeon X3440 processors with 4 cores and 8 threads
clocked at 2.53 GHz. No throughput losses are noted with the seg6local
BPF hook when the BPF program does nothing (440kpps). Adding a 8-bytes
TLV (1 call each to bpf_lwt_seg6_adjust_srh and bpf_lwt_seg6_store_bytes)
drops the throughput to 410kpps, and inlining a SRH via
bpf_lwt_seg6_action drops the throughput to 420kpps.
All throughputs are stable.
-------
v2: move the SRH integrity state from skb->cb to a per-cpu buffer
v3: - document helpers in man-page style
- fix kbuild bugs
- un-break BPF LWT out hook
- bpf_push_seg6_encap is now static
- preempt_enable is now called when the packet is dropped in
input_action_end_bpf
v4: fix kbuild bugs when CONFIG_IPV6=m
v5: fix kbuild sparse warnings when CONFIG_IPV6=m
v6: fix skb pointers-related bugs in helpers
v7: - fix memory leak in error path of End.BPF setup
- add freeing of BPF data in seg6_local_destroy_state
- new enums SEG6_LOCAL_BPF_* instead of re-using ones of lwt bpf for
netlink nested bpf attributes
- SEG6_LOCAL_BPF_PROG attr now contains prog->aux->id when dumping
state
Thanks.
Mathieu Xhonneux (6):
ipv6: sr: make seg6.h includable without IPv6
ipv6: sr: export function lookup_nexthop
bpf: Add IPv6 Segment Routing helpers
bpf: Split lwt inout verifier structures
ipv6: sr: Add seg6local action End.BPF
selftests/bpf: test for seg6local End.BPF action
include/linux/bpf_types.h | 5 +-
include/net/seg6.h | 7 +-
include/net/seg6_local.h | 32 ++
include/uapi/linux/bpf.h | 97 ++++-
include/uapi/linux/seg6_local.h | 12 +
kernel/bpf/verifier.c | 1 +
net/core/filter.c | 393 ++++++++++++++++---
net/ipv6/Kconfig | 5 +
net/ipv6/seg6_local.c | 190 +++++++++-
tools/include/uapi/linux/bpf.h | 97 ++++-
tools/lib/bpf/libbpf.c | 1 +
tools/testing/selftests/bpf/Makefile | 6 +-
tools/testing/selftests/bpf/bpf_helpers.h | 12 +
tools/testing/selftests/bpf/test_lwt_seg6local.c | 437 ++++++++++++++++++++++
tools/testing/selftests/bpf/test_lwt_seg6local.sh | 140 +++++++
15 files changed, 1363 insertions(+), 72 deletions(-)
create mode 100644 include/net/seg6_local.h
create mode 100644 tools/testing/selftests/bpf/test_lwt_seg6local.c
create mode 100755 tools/testing/selftests/bpf/test_lwt_seg6local.sh
--
2.16.1
^ permalink raw reply
* [PATCH bpf-next v7 1/6] ipv6: sr: make seg6.h includable without IPv6
From: Mathieu Xhonneux @ 2018-05-20 13:58 UTC (permalink / raw)
To: netdev; +Cc: daniel, dlebrun, alexei.starovoitov
In-Reply-To: <cover.1526824042.git.m.xhonneux@gmail.com>
include/net/seg6.h cannot be included in a source file if CONFIG_IPV6 is
not enabled:
include/net/seg6.h: In function 'seg6_pernet':
>> include/net/seg6.h:52:14: error: 'struct net' has no member named
'ipv6'; did you mean 'ipv4'?
return net->ipv6.seg6_data;
^~~~
ipv4
This commit makes seg6_pernet return NULL if IPv6 is not compiled, hence
allowing seg6.h to be included regardless of the configuration.
Signed-off-by: Mathieu Xhonneux <m.xhonneux@gmail.com>
---
include/net/seg6.h | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/include/net/seg6.h b/include/net/seg6.h
index 099bad59dc90..70b4cfac52d7 100644
--- a/include/net/seg6.h
+++ b/include/net/seg6.h
@@ -49,7 +49,11 @@ struct seg6_pernet_data {
static inline struct seg6_pernet_data *seg6_pernet(struct net *net)
{
+#if IS_ENABLED(CONFIG_IPV6)
return net->ipv6.seg6_data;
+#else
+ return NULL;
+#endif
}
extern int seg6_init(void);
--
2.16.1
^ permalink raw reply related
* [PATCH bpf-next v7 2/6] ipv6: sr: export function lookup_nexthop
From: Mathieu Xhonneux @ 2018-05-20 13:58 UTC (permalink / raw)
To: netdev; +Cc: daniel, dlebrun, alexei.starovoitov
In-Reply-To: <cover.1526824042.git.m.xhonneux@gmail.com>
The function lookup_nexthop is essential to implement most of the seg6local
actions. As we want to provide a BPF helper allowing to apply some of these
actions on the packet being processed, the helper should be able to call
this function, hence the need to make it public.
Moreover, if one argument is incorrect or if the next hop can not be found,
an error should be returned by the BPF helper so the BPF program can adapt
its processing of the packet (return an error, properly force the drop,
...). This patch hence makes this function return dst->error to indicate a
possible error.
Signed-off-by: Mathieu Xhonneux <m.xhonneux@gmail.com>
Acked-by: David Lebrun <dlebrun@google.com>
---
include/net/seg6.h | 3 ++-
include/net/seg6_local.h | 24 ++++++++++++++++++++++++
net/ipv6/seg6_local.c | 20 +++++++++++---------
3 files changed, 37 insertions(+), 10 deletions(-)
create mode 100644 include/net/seg6_local.h
diff --git a/include/net/seg6.h b/include/net/seg6.h
index 70b4cfac52d7..e029e301faa5 100644
--- a/include/net/seg6.h
+++ b/include/net/seg6.h
@@ -67,5 +67,6 @@ extern bool seg6_validate_srh(struct ipv6_sr_hdr *srh, int len);
extern int seg6_do_srh_encap(struct sk_buff *skb, struct ipv6_sr_hdr *osrh,
int proto);
extern int seg6_do_srh_inline(struct sk_buff *skb, struct ipv6_sr_hdr *osrh);
-
+extern int seg6_lookup_nexthop(struct sk_buff *skb, struct in6_addr *nhaddr,
+ u32 tbl_id);
#endif
diff --git a/include/net/seg6_local.h b/include/net/seg6_local.h
new file mode 100644
index 000000000000..57498b23085d
--- /dev/null
+++ b/include/net/seg6_local.h
@@ -0,0 +1,24 @@
+/*
+ * SR-IPv6 implementation
+ *
+ * Authors:
+ * David Lebrun <david.lebrun@uclouvain.be>
+ * eBPF support: Mathieu Xhonneux <m.xhonneux@gmail.com>
+ *
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ */
+
+#ifndef _NET_SEG6_LOCAL_H
+#define _NET_SEG6_LOCAL_H
+
+#include <linux/net.h>
+#include <linux/ipv6.h>
+
+extern int seg6_lookup_nexthop(struct sk_buff *skb, struct in6_addr *nhaddr,
+ u32 tbl_id);
+
+#endif
diff --git a/net/ipv6/seg6_local.c b/net/ipv6/seg6_local.c
index 45722327375a..e9b23fb924ad 100644
--- a/net/ipv6/seg6_local.c
+++ b/net/ipv6/seg6_local.c
@@ -30,6 +30,7 @@
#ifdef CONFIG_IPV6_SEG6_HMAC
#include <net/seg6_hmac.h>
#endif
+#include <net/seg6_local.h>
#include <linux/etherdevice.h>
struct seg6_local_lwt;
@@ -140,8 +141,8 @@ static void advance_nextseg(struct ipv6_sr_hdr *srh, struct in6_addr *daddr)
*daddr = *addr;
}
-static void lookup_nexthop(struct sk_buff *skb, struct in6_addr *nhaddr,
- u32 tbl_id)
+int seg6_lookup_nexthop(struct sk_buff *skb, struct in6_addr *nhaddr,
+ u32 tbl_id)
{
struct net *net = dev_net(skb->dev);
struct ipv6hdr *hdr = ipv6_hdr(skb);
@@ -187,6 +188,7 @@ static void lookup_nexthop(struct sk_buff *skb, struct in6_addr *nhaddr,
skb_dst_drop(skb);
skb_dst_set(skb, dst);
+ return dst->error;
}
/* regular endpoint function */
@@ -200,7 +202,7 @@ static int input_action_end(struct sk_buff *skb, struct seg6_local_lwt *slwt)
advance_nextseg(srh, &ipv6_hdr(skb)->daddr);
- lookup_nexthop(skb, NULL, 0);
+ seg6_lookup_nexthop(skb, NULL, 0);
return dst_input(skb);
@@ -220,7 +222,7 @@ static int input_action_end_x(struct sk_buff *skb, struct seg6_local_lwt *slwt)
advance_nextseg(srh, &ipv6_hdr(skb)->daddr);
- lookup_nexthop(skb, &slwt->nh6, 0);
+ seg6_lookup_nexthop(skb, &slwt->nh6, 0);
return dst_input(skb);
@@ -239,7 +241,7 @@ static int input_action_end_t(struct sk_buff *skb, struct seg6_local_lwt *slwt)
advance_nextseg(srh, &ipv6_hdr(skb)->daddr);
- lookup_nexthop(skb, NULL, slwt->table);
+ seg6_lookup_nexthop(skb, NULL, slwt->table);
return dst_input(skb);
@@ -331,7 +333,7 @@ static int input_action_end_dx6(struct sk_buff *skb,
if (!ipv6_addr_any(&slwt->nh6))
nhaddr = &slwt->nh6;
- lookup_nexthop(skb, nhaddr, 0);
+ seg6_lookup_nexthop(skb, nhaddr, 0);
return dst_input(skb);
drop:
@@ -380,7 +382,7 @@ static int input_action_end_dt6(struct sk_buff *skb,
if (!pskb_may_pull(skb, sizeof(struct ipv6hdr)))
goto drop;
- lookup_nexthop(skb, NULL, slwt->table);
+ seg6_lookup_nexthop(skb, NULL, slwt->table);
return dst_input(skb);
@@ -406,7 +408,7 @@ static int input_action_end_b6(struct sk_buff *skb, struct seg6_local_lwt *slwt)
ipv6_hdr(skb)->payload_len = htons(skb->len - sizeof(struct ipv6hdr));
skb_set_transport_header(skb, sizeof(struct ipv6hdr));
- lookup_nexthop(skb, NULL, 0);
+ seg6_lookup_nexthop(skb, NULL, 0);
return dst_input(skb);
@@ -438,7 +440,7 @@ static int input_action_end_b6_encap(struct sk_buff *skb,
ipv6_hdr(skb)->payload_len = htons(skb->len - sizeof(struct ipv6hdr));
skb_set_transport_header(skb, sizeof(struct ipv6hdr));
- lookup_nexthop(skb, NULL, 0);
+ seg6_lookup_nexthop(skb, NULL, 0);
return dst_input(skb);
--
2.16.1
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox