@@ -1153,6 +1153,22 @@ static int ipgre_netlink_parms(struct net_device *dev,
1153
1153
if (data [IFLA_GRE_FWMARK ])
1154
1154
* fwmark = nla_get_u32 (data [IFLA_GRE_FWMARK ]);
1155
1155
1156
+ return 0 ;
1157
+ }
1158
+
1159
+ static int erspan_netlink_parms (struct net_device * dev ,
1160
+ struct nlattr * data [],
1161
+ struct nlattr * tb [],
1162
+ struct ip_tunnel_parm * parms ,
1163
+ __u32 * fwmark )
1164
+ {
1165
+ struct ip_tunnel * t = netdev_priv (dev );
1166
+ int err ;
1167
+
1168
+ err = ipgre_netlink_parms (dev , data , tb , parms , fwmark );
1169
+ if (err )
1170
+ return err ;
1171
+
1156
1172
if (data [IFLA_GRE_ERSPAN_VER ]) {
1157
1173
t -> erspan_ver = nla_get_u8 (data [IFLA_GRE_ERSPAN_VER ]);
1158
1174
@@ -1276,45 +1292,70 @@ static void ipgre_tap_setup(struct net_device *dev)
1276
1292
ip_tunnel_setup (dev , gre_tap_net_id );
1277
1293
}
1278
1294
1279
- static int ipgre_newlink (struct net * src_net , struct net_device * dev ,
1280
- struct nlattr * tb [], struct nlattr * data [],
1281
- struct netlink_ext_ack * extack )
1295
+ static int
1296
+ ipgre_newlink_encap_setup (struct net_device * dev , struct nlattr * data [])
1282
1297
{
1283
- struct ip_tunnel_parm p ;
1284
1298
struct ip_tunnel_encap ipencap ;
1285
- __u32 fwmark = 0 ;
1286
- int err ;
1287
1299
1288
1300
if (ipgre_netlink_encap_parms (data , & ipencap )) {
1289
1301
struct ip_tunnel * t = netdev_priv (dev );
1290
- err = ip_tunnel_encap_setup (t , & ipencap );
1302
+ int err = ip_tunnel_encap_setup (t , & ipencap );
1291
1303
1292
1304
if (err < 0 )
1293
1305
return err ;
1294
1306
}
1295
1307
1308
+ return 0 ;
1309
+ }
1310
+
1311
+ static int ipgre_newlink (struct net * src_net , struct net_device * dev ,
1312
+ struct nlattr * tb [], struct nlattr * data [],
1313
+ struct netlink_ext_ack * extack )
1314
+ {
1315
+ struct ip_tunnel_parm p ;
1316
+ __u32 fwmark = 0 ;
1317
+ int err ;
1318
+
1319
+ err = ipgre_newlink_encap_setup (dev , data );
1320
+ if (err )
1321
+ return err ;
1322
+
1296
1323
err = ipgre_netlink_parms (dev , data , tb , & p , & fwmark );
1297
1324
if (err < 0 )
1298
1325
return err ;
1299
1326
return ip_tunnel_newlink (dev , tb , & p , fwmark );
1300
1327
}
1301
1328
1329
+ static int erspan_newlink (struct net * src_net , struct net_device * dev ,
1330
+ struct nlattr * tb [], struct nlattr * data [],
1331
+ struct netlink_ext_ack * extack )
1332
+ {
1333
+ struct ip_tunnel_parm p ;
1334
+ __u32 fwmark = 0 ;
1335
+ int err ;
1336
+
1337
+ err = ipgre_newlink_encap_setup (dev , data );
1338
+ if (err )
1339
+ return err ;
1340
+
1341
+ err = erspan_netlink_parms (dev , data , tb , & p , & fwmark );
1342
+ if (err )
1343
+ return err ;
1344
+ return ip_tunnel_newlink (dev , tb , & p , fwmark );
1345
+ }
1346
+
1302
1347
static int ipgre_changelink (struct net_device * dev , struct nlattr * tb [],
1303
1348
struct nlattr * data [],
1304
1349
struct netlink_ext_ack * extack )
1305
1350
{
1306
1351
struct ip_tunnel * t = netdev_priv (dev );
1307
- struct ip_tunnel_encap ipencap ;
1308
1352
__u32 fwmark = t -> fwmark ;
1309
1353
struct ip_tunnel_parm p ;
1310
1354
int err ;
1311
1355
1312
- if (ipgre_netlink_encap_parms (data , & ipencap )) {
1313
- err = ip_tunnel_encap_setup (t , & ipencap );
1314
-
1315
- if (err < 0 )
1316
- return err ;
1317
- }
1356
+ err = ipgre_newlink_encap_setup (dev , data );
1357
+ if (err )
1358
+ return err ;
1318
1359
1319
1360
err = ipgre_netlink_parms (dev , data , tb , & p , & fwmark );
1320
1361
if (err < 0 )
@@ -1327,8 +1368,34 @@ static int ipgre_changelink(struct net_device *dev, struct nlattr *tb[],
1327
1368
t -> parms .i_flags = p .i_flags ;
1328
1369
t -> parms .o_flags = p .o_flags ;
1329
1370
1330
- if (strcmp (dev -> rtnl_link_ops -> kind , "erspan" ))
1331
- ipgre_link_update (dev , !tb [IFLA_MTU ]);
1371
+ ipgre_link_update (dev , !tb [IFLA_MTU ]);
1372
+
1373
+ return 0 ;
1374
+ }
1375
+
1376
+ static int erspan_changelink (struct net_device * dev , struct nlattr * tb [],
1377
+ struct nlattr * data [],
1378
+ struct netlink_ext_ack * extack )
1379
+ {
1380
+ struct ip_tunnel * t = netdev_priv (dev );
1381
+ __u32 fwmark = t -> fwmark ;
1382
+ struct ip_tunnel_parm p ;
1383
+ int err ;
1384
+
1385
+ err = ipgre_newlink_encap_setup (dev , data );
1386
+ if (err )
1387
+ return err ;
1388
+
1389
+ err = erspan_netlink_parms (dev , data , tb , & p , & fwmark );
1390
+ if (err < 0 )
1391
+ return err ;
1392
+
1393
+ err = ip_tunnel_changelink (dev , tb , & p , fwmark );
1394
+ if (err < 0 )
1395
+ return err ;
1396
+
1397
+ t -> parms .i_flags = p .i_flags ;
1398
+ t -> parms .o_flags = p .o_flags ;
1332
1399
1333
1400
return 0 ;
1334
1401
}
@@ -1519,8 +1586,8 @@ static struct rtnl_link_ops erspan_link_ops __read_mostly = {
1519
1586
.priv_size = sizeof (struct ip_tunnel ),
1520
1587
.setup = erspan_setup ,
1521
1588
.validate = erspan_validate ,
1522
- .newlink = ipgre_newlink ,
1523
- .changelink = ipgre_changelink ,
1589
+ .newlink = erspan_newlink ,
1590
+ .changelink = erspan_changelink ,
1524
1591
.dellink = ip_tunnel_dellink ,
1525
1592
.get_size = ipgre_get_size ,
1526
1593
.fill_info = ipgre_fill_info ,
0 commit comments