-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathubuntu-1804-4.15.diff
5542 lines (5358 loc) · 147 KB
/
ubuntu-1804-4.15.diff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index 0936da592e12..b4b0edd30881 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -1,3 +1,20 @@
+#
+# Network Provisioning Domain configuration
+#
+
+menuconfig NETPVD
+ default y if UML
+ depends on NET
+ bool "Network PvD support"
+ ---help---
+ You can say N here if you don't intend to connect your Linux box to
+ any other computer at all.
+
+ You'll have to say Y if applications intend to make use of the
+ provisioning domain feature
+
+ If unsure, say Y.
+
#
# Network device configuration
#
diff --git a/drivers/scsi/cxgbi/libcxgbi.c b/drivers/scsi/cxgbi/libcxgbi.c
index ce1336414e0a..79e58726f29e 100644
--- a/drivers/scsi/cxgbi/libcxgbi.c
+++ b/drivers/scsi/cxgbi/libcxgbi.c
@@ -788,7 +788,7 @@ cxgbi_check_route6(struct sockaddr *dst_addr, int ifindex)
struct inet6_dev *idev = ip6_dst_idev((struct dst_entry *)rt);
err = ipv6_dev_get_saddr(&init_net, idev ? idev->dev : NULL,
- &daddr6->sin6_addr, 0, &pref_saddr);
+ &daddr6->sin6_addr, 0, /*PvD*/ NULL, &pref_saddr);
if (err) {
pr_info("failed to get source address to reach %pI6\n",
&daddr6->sin6_addr);
diff --git a/include/linux/inet.h b/include/linux/inet.h
index 636ebe87e6f8..016bc148c60b 100644
--- a/include/linux/inet.h
+++ b/include/linux/inet.h
@@ -60,4 +60,5 @@ extern int in6_pton(const char *src, int srclen, u8 *dst, int delim, const char
extern int inet_pton_with_scope(struct net *net, unsigned short af,
const char *src, const char *port, struct sockaddr_storage *addr);
+extern char *addr6tostr(u8 const *addr, char *str);
#endif /* _LINUX_INET_H */
diff --git a/include/linux/ipv6.h b/include/linux/ipv6.h
index 8415bf1a9776..90862cadc976 100644
--- a/include/linux/ipv6.h
+++ b/include/linux/ipv6.h
@@ -75,6 +75,10 @@ struct ipv6_devconf {
__s32 disable_policy;
__s32 ndisc_tclass;
+#ifdef CONFIG_NETPVD
+ __u32 parse_pvd;
+#endif
+
struct ctl_table_header *sysctl_header;
};
diff --git a/include/linux/sched.h b/include/linux/sched.h
index d2588263a989..8311416c34e4 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -1087,7 +1087,9 @@ struct task_struct {
/* Used by LSM modules for access restriction: */
void *security;
#endif
-
+#ifdef CONFIG_NETPVD
+ char *bound_pvd; /* 0 : inherit; -1 : unset, otherwise : set */
+#endif
/*
* New fields for task_struct should be added above here, so that
* they are included in the randomized portion of task_struct.
diff --git a/include/net/addrconf.h b/include/net/addrconf.h
index b623b65a79d1..332bd73f0060 100644
--- a/include/net/addrconf.h
+++ b/include/net/addrconf.h
@@ -88,6 +88,7 @@ struct inet6_ifaddr *ipv6_get_ifaddr(struct net *net,
int ipv6_dev_get_saddr(struct net *net, const struct net_device *dev,
const struct in6_addr *daddr, unsigned int srcprefs,
+ void *pvd,
struct in6_addr *saddr);
int __ipv6_get_lladdr(struct inet6_dev *idev, struct in6_addr *addr,
u32 banned_flags);
@@ -99,14 +100,16 @@ void addrconf_join_solict(struct net_device *dev, const struct in6_addr *addr);
void addrconf_leave_solict(struct inet6_dev *idev, const struct in6_addr *addr);
void addrconf_add_linklocal(struct inet6_dev *idev,
- const struct in6_addr *addr, u32 flags);
+ const struct in6_addr *addr, u32 flags,
+ void *pvd);
int addrconf_prefix_rcv_add_addr(struct net *net, struct net_device *dev,
const struct prefix_info *pinfo,
struct inet6_dev *in6_dev,
const struct in6_addr *addr, int addr_type,
u32 addr_flags, bool sllao, bool tokenized,
- __u32 valid_lft, u32 prefered_lft);
+ __u32 valid_lft, u32 prefered_lft,
+ void *pvd);
static inline void addrconf_addr_eui48_base(u8 *eui, const char *const addr)
{
@@ -257,7 +260,8 @@ static inline bool ipv6_is_mld(struct sk_buff *skb, int nexthdr, int offset)
}
void addrconf_prefix_rcv(struct net_device *dev,
- u8 *opt, int len, bool sllao);
+ u8 *opt, int len, bool sllao,
+ void *pvd);
/*
* anycast prototypes (anycast.c)
diff --git a/include/net/flow.h b/include/net/flow.h
index f1624fd5b1d0..949f54187291 100644
--- a/include/net/flow.h
+++ b/include/net/flow.h
@@ -151,6 +151,10 @@ struct flowi6 {
#define fl6_mh_type uli.mht.type
#define fl6_gre_key uli.gre_key
__u32 mp_hash;
+#ifdef CONFIG_NETPVD
+ void *pvd;
+#define fl6_pvd pvd
+#endif
} __attribute__((__aligned__(BITS_PER_LONG/8)));
struct flowidn {
diff --git a/include/net/if_inet6.h b/include/net/if_inet6.h
index d4088d1a688d..18c088bad9ed 100644
--- a/include/net/if_inet6.h
+++ b/include/net/if_inet6.h
@@ -42,6 +42,7 @@ enum {
struct inet6_ifaddr {
struct in6_addr addr;
__u32 prefix_len;
+ void *pvd;
/* In seconds, relative to tstamp. Expiry is at tstamp + HZ * lft. */
__u32 valid_lft;
diff --git a/include/net/ip6_fib.h b/include/net/ip6_fib.h
index 10c913816032..69225761750f 100644
--- a/include/net/ip6_fib.h
+++ b/include/net/ip6_fib.h
@@ -65,6 +65,10 @@ struct fib6_config {
struct nl_info fc_nlinfo;
struct nlattr *fc_encap;
u16 fc_encap_type;
+
+#ifdef CONFIG_NETPVD
+ void *fc_pvd;
+#endif
};
struct fib6_node {
@@ -172,6 +176,12 @@ struct rt6_info {
u8 rt6i_protocol;
u8 exception_bucket_flushed:1,
unused:7;
+ /*
+ * TODO : check if adding fields in this structure
+ * does not trash cache lines (CONFIG_NETPVD)
+ */
+ /* WQ: why not englobed in CONFIG_NETPVD*/
+ void *rt6i_pvd;
};
#define for_each_fib6_node_rt_rcu(fn) \
diff --git a/include/net/ip6_route.h b/include/net/ip6_route.h
index 18e442ea93d8..5de369848059 100644
--- a/include/net/ip6_route.h
+++ b/include/net/ip6_route.h
@@ -35,6 +35,9 @@ struct route_info {
#define RT6_LOOKUP_F_SRCPREF_PUBLIC 0x00000010
#define RT6_LOOKUP_F_SRCPREF_COA 0x00000020
#define RT6_LOOKUP_F_IGNORE_LINKSTATE 0x00000040
+#ifdef CONFIG_NETPVD
+#define RT6_LOOKUP_F_PVD 0x00000080
+#endif
/* We do not (yet ?) support IPv6 jumbograms (RFC 2675)
* Unlike IPv4, hdr->seg_len doesn't include the IPv6 header
@@ -104,6 +107,7 @@ void rt6_age_exceptions(struct rt6_info *rt, struct fib6_gc_args *gc_args,
static inline int ip6_route_get_saddr(struct net *net, struct rt6_info *rt,
const struct in6_addr *daddr,
unsigned int prefs,
+ void *pvd,
struct in6_addr *saddr)
{
struct inet6_dev *idev =
@@ -114,7 +118,7 @@ static inline int ip6_route_get_saddr(struct net *net, struct rt6_info *rt,
*saddr = rt->rt6i_prefsrc.addr;
else
err = ipv6_dev_get_saddr(net, idev ? idev->dev : NULL,
- daddr, prefs, saddr);
+ daddr, prefs, pvd, saddr);
return err;
}
@@ -128,7 +132,9 @@ struct dst_entry *icmp6_dst_alloc(struct net_device *dev, struct flowi6 *fl6);
void fib6_force_start_gc(struct net *net);
struct rt6_info *addrconf_dst_alloc(struct inet6_dev *idev,
- const struct in6_addr *addr, bool anycast);
+ const struct in6_addr *addr,
+ void *pvd, /* CONFIG_NETPVD */
+ bool anycast);
struct rt6_info *ip6_dst_alloc(struct net *net, struct net_device *dev,
int flags);
@@ -145,7 +151,11 @@ struct rt6_info *rt6_add_dflt_router(const struct in6_addr *gwaddr,
void rt6_purge_dflt_routers(struct net *net);
int rt6_route_rcv(struct net_device *dev, u8 *opt, int len,
- const struct in6_addr *gwaddr);
+ const struct in6_addr *gwaddr,
+ void *pvd); /* CONFIG_NETPVD */
+int ip6_route_pvd_attach(struct sock *sk,
+ char __user *optval,
+ int optlen);
void ip6_update_pmtu(struct sk_buff *skb, struct net *net, __be32 mtu, int oif,
u32 mark, kuid_t uid);
diff --git a/include/net/ipv6.h b/include/net/ipv6.h
index 221238254eb7..550677f370b3 100644
--- a/include/net/ipv6.h
+++ b/include/net/ipv6.h
@@ -378,6 +378,14 @@ static inline bool ipv6_accept_ra(struct inet6_dev *idev)
idev->cnf.accept_ra;
}
+#ifdef CONFIG_NETPVD
+static inline bool ipv6_parse_pvd(struct inet6_dev *idev)
+{
+ return ipv6_accept_ra(idev) ? idev->cnf.parse_pvd : false;
+}
+#endif
+
+
#if IS_ENABLED(CONFIG_IPV6)
static inline int ip6_frag_mem(struct net *net)
{
diff --git a/include/net/ndisc.h b/include/net/ndisc.h
index ddfbb591e2c5..6e146fbab4c1 100644
--- a/include/net/ndisc.h
+++ b/include/net/ndisc.h
@@ -38,6 +38,9 @@ enum {
ND_OPT_RDNSS = 25, /* RFC5006 */
ND_OPT_DNSSL = 31, /* RFC6106 */
ND_OPT_6CO = 34, /* RFC6775 */
+#ifdef CONFIG_NETPVD
+ ND_OPT_PVDID = 21, /* temporary allocation from IANA*/
+#endif
__ND_OPT_MAX
};
@@ -53,6 +56,9 @@ enum {
#include <linux/if_arp.h>
#include <linux/netdevice.h>
#include <linux/hash.h>
+#ifdef CONFIG_NETPVD
+#include<net/pvd.h>
+#endif
#include <net/neighbour.h>
@@ -103,6 +109,14 @@ struct nd_opt_hdr {
__u8 nd_opt_len;
} __packed;
+struct nd_opt_pvdid {
+ uint8_t nd_opt_pvdid_type;
+ uint8_t nd_opt_pvdid_len;
+ uint16_t nd_opt_pvdid_flags;
+ uint16_t nd_opt_pvdid_sequence_number;
+ unsigned char nd_opt_pvdid_name[];
+};
+
/* ND options */
struct ndisc_options {
struct nd_opt_hdr *nd_opt_array[__ND_OPT_ARRAY_MAX];
@@ -115,6 +129,9 @@ struct ndisc_options {
#if IS_ENABLED(CONFIG_IEEE802154_6LOWPAN)
struct nd_opt_hdr *nd_802154_opt_array[ND_OPT_TARGET_LL_ADDR + 1];
#endif
+#ifdef CONFIG_NETPVD
+ struct nd_opt_hdr *nd_opt_pvdid;
+#endif
};
#define nd_opts_src_lladdr nd_opt_array[ND_OPT_SOURCE_LL_ADDR]
@@ -129,6 +146,24 @@ struct ndisc_options {
#define NDISC_OPT_SPACE(len) (((len)+2+7)&~7)
+#ifdef CONFIG_NETPVD
+/* datastruct for PvD option parsing */
+struct pvd_header {
+ char pvdname[PVDNAMSIZ];
+ int pvd_sequence_number;
+ int pvd_h_flag;
+ int pvd_l_flag;
+ /* introduced in draft 01, when set in RA message,
+ this variable indicates the offset in unit of byte
+ to reach RA header from the beginning of the PvD option, when a flag set;
+ otherwise it equals to 0. */
+ int pvd_a_flag;
+ /* the offset in byte from the beginning of the PvD option to the next RA option
+ helps skip PvD header and PvD ID (floating length) in option iterator */
+ int offset_to_opt;
+};
+#endif
+
struct ndisc_options *ndisc_parse_options(const struct net_device *dev,
u8 *opt, int opt_len,
struct ndisc_options *ndopts);
@@ -216,7 +251,8 @@ struct ndisc_ops {
int addr_type, u32 addr_flags,
bool sllao, bool tokenized,
__u32 valid_lft, u32 prefered_lft,
- bool dev_addr_generated);
+ bool dev_addr_generated,
+ void *pvd);
};
#if IS_ENABLED(CONFIG_IPV6)
@@ -296,7 +332,8 @@ static inline void ndisc_ops_prefix_rcv_add_addr(struct net *net,
bool sllao, bool tokenized,
__u32 valid_lft,
u32 prefered_lft,
- bool dev_addr_generated)
+ bool dev_addr_generated,
+ void *pvd)
{
if (dev->ndisc_ops && dev->ndisc_ops->prefix_rcv_add_addr)
dev->ndisc_ops->prefix_rcv_add_addr(net, dev, pinfo, in6_dev,
@@ -304,7 +341,8 @@ static inline void ndisc_ops_prefix_rcv_add_addr(struct net *net,
addr_flags, sllao,
tokenized, valid_lft,
prefered_lft,
- dev_addr_generated);
+ dev_addr_generated,
+ pvd);
}
#endif
diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h
index 049008493faf..1995c041b7ae 100644
--- a/include/net/net_namespace.h
+++ b/include/net/net_namespace.h
@@ -42,11 +42,17 @@ struct ctl_table_header;
struct net_generic;
struct sock;
struct netns_ipvs;
-
+struct pvd; /* anonymous */ /*WQ: CONFIG_NETPVD?*/
#define NETDEV_HASHBITS 8
#define NETDEV_HASHENTRIES (1 << NETDEV_HASHBITS)
+#ifdef CONFIG_NETPVD
+#define NETPVD_HASHBITS 8
+#define NETPVD_HASHENTRIES (1 << NETPVD_HASHBITS)
+#include <linux/pvd-user.h>
+#endif
+
struct net {
refcount_t passive; /* To decided when the network
* namespace should be freed.
@@ -86,6 +92,17 @@ struct net {
int ifindex;
unsigned int dev_unreg_count;
+#ifdef CONFIG_NETPVD
+ struct list_head pvd_base_head;
+ struct hlist_head *pvd_name_head;
+ struct hlist_head *pvd_index_head;
+ u32 pvdindex;
+ struct timer_list pvd_timer;
+#ifdef CONFIG_PROC_FS
+ struct proc_dir_entry *proc_pvdd;
+#endif
+#endif /* CONFIG_NETPVD */
+
/* core fib_rules */
struct list_head rules_ops;
diff --git a/include/net/pvd.h b/include/net/pvd.h
new file mode 100644
index 000000000000..241dc2fc778e
--- /dev/null
+++ b/include/net/pvd.h
@@ -0,0 +1,204 @@
+
+#ifndef _NET_PVD_H
+#define _NET_PVD_H
+
+#ifdef CONFIG_NETPVD
+
+#include <net/net_namespace.h>
+#include <linux/percpu.h>
+#include <linux/hash.h>
+#include <linux/list.h>
+#include <linux/rculist.h>
+
+#include <linux/pvd-user.h>
+
+struct net_pvd {
+ /*
+ * for explicit PvDs, its name is the FDQN
+ * for implicit PvD, its name is router lla plus '%' plus receivng dev name
+ */
+ char name[PVDNAMSIZ];
+ int __percpu *pcpu_refcnt;
+ u32 pvdindex;
+ int notifications_blocked;
+
+ struct hlist_node name_hlist;
+ struct hlist_node index_hlist;
+ struct list_head pvd_list;
+
+ /*
+ * Attributes of the pvd
+ */
+ int sequence_number;
+ int h_flag;
+ int l_flag;
+ int a_flag; /* introduced in draft 01 */
+ int implicit_flag;
+
+ /*
+ * Lot of cross references to other structures belonging to
+ * this PvD. We have to make sure that we are not referencing
+ * released pointers (dev, lla, etc.)
+ */
+ possible_net_t nd_net;
+
+ struct net_device *dev; /* the device it has been received on */
+ struct in6_addr lla; /* the associated router lla */
+ int nroutes;
+ struct rt6_info *routes[MAXROUTESPERPVD];
+ int naddresses;
+ struct inet6_ifaddr *addresses[MAXADDRPERPVD];
+
+ /*
+ * The user options below have no existence somewhere
+ * in the kernel. They are just stored here to
+ * be provided to the applications
+ */
+ int ndnssl;
+ char *dnssl[MAXDNSSLPERPVD];
+ unsigned long dnsslExpire[MAXDNSSLPERPVD];
+
+
+ int nrdnss;
+ struct in6_addr rdnss[MAXRDNSSPERPVD];
+ unsigned long rdnssExpire[MAXRDNSSPERPVD];
+
+#ifdef CONFIG_NETPVD
+ /*
+ * pvd.d/
+ * <pvdname>/
+ * attrs
+ * routes
+ * addrs
+ * sockets
+ */
+ struct proc_dir_entry *proc_pvd; /* dir */
+ struct proc_dir_entry *proc_pvd_attrs; /* file */
+ struct proc_dir_entry *proc_pvd_routes; /* file */
+ struct proc_dir_entry *proc_pvd_addrs; /* file */
+ struct proc_dir_entry *proc_pvd_rdnss; /* file */
+ struct proc_dir_entry *proc_pvd_dnssl; /* file */
+ struct proc_dir_entry *proc_pvd_sockets; /* file */
+#endif
+};
+
+/*
+ * Bound PvDs. Binding to a set of PvDs can be done at 3 different hierarchical levels
+ * 1) the socket
+ * 2) the thread
+ * 3) the process
+ *
+ * We define here a structure that can be shared between these 3 levels
+ */
+struct kernel_bind_to_pvd {
+ int refcnt;
+ struct bind_to_pvd btp;
+};
+
+
+/**
+ * pvd_put - release reference to pvd
+ * @pvd: pvd
+ *
+ * Release reference to pvd to allow it to be freed.
+ */
+static inline void pvd_put(struct net_pvd *pvd)
+{
+ if (pvd != NULL) {
+ this_cpu_dec(*pvd->pcpu_refcnt);
+ }
+}
+
+/**
+ * pvd_hold - get reference to pvd
+ * @pvd: pvd
+ *
+ * Hold reference to pvd to keep it from being freed.
+ */
+static inline struct net_pvd *pvd_hold(struct net_pvd *pvd)
+{
+ if (pvd != NULL) {
+ this_cpu_inc(*pvd->pcpu_refcnt);
+ }
+ return pvd;
+}
+
+/*
+ * Net namespace inlines
+ */
+static inline struct net *pvd_net(const struct net_pvd *pvd)
+{
+ return read_pnet(&pvd->nd_net);
+}
+
+static inline void pvd_net_set(struct net_pvd *pvd, struct net *net)
+{
+ write_pnet(&pvd->nd_net, net);
+}
+
+extern void pvd_rtnl_notify(struct net_pvd *pvd, int state);
+extern void pvd_register_dnssl(struct net_pvd *pvd, void *dnssl_opt);
+extern void pvd_register_rdnss(struct net_pvd *pvd, void *rdnss_opt);
+extern int pvd_migrate_route(
+ struct net_pvd *newpvd,
+ struct rt6_info *rt);
+extern int pvd_migrate_route_rtnl(
+ struct net_pvd *newpvd,
+ struct rt6_info *rt);
+extern int pvd_migrate_addr(
+ struct net_pvd *newpvd,
+ struct inet6_ifaddr *addr);
+extern int pvd_migrate_addr_rtnl(
+ struct net_pvd *newpvd,
+ struct inet6_ifaddr *addr);
+extern struct net_pvd *register_pvd(
+ struct net *net,
+ char *pvdname,
+ struct net_device *dev,
+ struct in6_addr *lla);
+extern void unregister_pvd(struct net_pvd *pvd);
+extern struct net_pvd *pvd_get_by_name_rcu(
+ struct net *net,
+ const char *pvdname,
+ struct net_device *dev,
+ struct in6_addr *lla);
+extern struct net_pvd *pvd_get_by_name(
+ struct net *net,
+ const char *pvdname,
+ struct net_device *dev,
+ struct in6_addr *lla);
+extern int pvd_get_index(struct net_pvd *pvd);
+extern struct net_pvd *pvd_get_by_index(struct net *net, int pvdindex);
+extern int pvdindex_get_by_dev(struct net_device *dev, u32 *pvdindex);
+extern int pvd_getboundpvd(struct sock *sk, struct net_pvd **pvd);
+extern int sock_getbindtopvd(struct sock *sk, char __user *optval,
+ int __user *optlen, int len);
+extern int sock_setbindtopvd(struct sock *sk, char __user *optval,
+ int optlen);
+extern int sock_getpvdattr(
+ struct sock *sk,
+ char __user *optval,
+ int __user *optlen,
+ int len);
+
+extern int sock_createpvd(
+ struct sock *sk,
+ char __user *optval,
+ int optlen);
+
+extern int sock_getpvdlist(
+ struct sock *sk,
+ char __user *optval,
+ int __user *optlen,
+ int len);
+
+/* WQ: following function not implemented
+ * extern int sock_getralist(
+ * struct sock *sk,
+ * char __user *optval,
+ * int __user *optlen,
+ * int len);
+ */
+#endif /* CONFIG_NETPVD */
+
+#endif /* _NET_PVD_H */
diff --git a/include/net/sock.h b/include/net/sock.h
index 7a7b14e9628a..447332488921 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -131,6 +131,7 @@ typedef __u64 __bitwise __addrpair;
* @skc_reuse: %SO_REUSEADDR setting
* @skc_reuseport: %SO_REUSEPORT setting
* @skc_bound_dev_if: bound device index if != 0
+ * @skc_bound_pvd_ix: bound pvd index if != 0
* @skc_bind_node: bind hash linkage for various protocol lookup tables
* @skc_portaddr_node: second hash linkage for UDP/UDP-Lite protocol
* @skc_prot: protocol handlers inside a network family
@@ -178,6 +179,10 @@ struct sock_common {
unsigned char skc_ipv6only:1;
unsigned char skc_net_refcnt:1;
int skc_bound_dev_if;
+#ifdef CONFIG_NETPVD
+ int skc_pvd_bind_type; /* 0 : inherit, 1 : unset, 2 : set */
+ int skc_bound_pvd; /* pvd index if type == 2 */
+#endif
union {
struct hlist_node skc_bind_node;
struct hlist_node skc_portaddr_node;
@@ -342,6 +347,8 @@ struct sock {
#define sk_ipv6only __sk_common.skc_ipv6only
#define sk_net_refcnt __sk_common.skc_net_refcnt
#define sk_bound_dev_if __sk_common.skc_bound_dev_if
+#define sk_pvd_bind_type __sk_common.skc_pvd_bind_type
+#define sk_bound_pvd __sk_common.skc_bound_pvd
#define sk_bind_node __sk_common.skc_bind_node
#define sk_prot __sk_common.skc_prot
#define sk_net __sk_common.skc_net
diff --git a/include/uapi/asm-generic/socket.h b/include/uapi/asm-generic/socket.h
index 0ae758c90e54..bcb26abd7b5f 100644
--- a/include/uapi/asm-generic/socket.h
+++ b/include/uapi/asm-generic/socket.h
@@ -107,4 +107,11 @@
#define SO_ZEROCOPY 60
+/* PVD specific options (FIXME : probably not the best place) */
+#define SO_BINDTOPVD 61
+#define SO_GETPVDLIST 62
+#define SO_GETPVDATTRIBUTES 63
+#define SO_CREATEPVD 64
+
+
#endif /* __ASM_GENERIC_SOCKET_H */
diff --git a/include/uapi/linux/if_addr.h b/include/uapi/linux/if_addr.h
index 2ef053d265de..303683af0a65 100644
--- a/include/uapi/linux/if_addr.h
+++ b/include/uapi/linux/if_addr.h
@@ -33,6 +33,7 @@ enum {
IFA_CACHEINFO,
IFA_MULTICAST,
IFA_FLAGS,
+ IFA_PVD,
__IFA_MAX,
};
diff --git a/include/uapi/linux/ipv6.h b/include/uapi/linux/ipv6.h
index 9c0f4a92bcff..7106b27d3aa2 100644
--- a/include/uapi/linux/ipv6.h
+++ b/include/uapi/linux/ipv6.h
@@ -187,6 +187,7 @@ enum {
DEVCONF_DISABLE_POLICY,
DEVCONF_ACCEPT_RA_RT_INFO_MIN_PLEN,
DEVCONF_NDISC_TCLASS,
+ DEVCONF_PARSE_PVD,
DEVCONF_MAX
};
diff --git a/include/uapi/linux/pvd-user.h b/include/uapi/linux/pvd-user.h
new file mode 100644
index 000000000000..0c20509e20fe
--- /dev/null
+++ b/include/uapi/linux/pvd-user.h
@@ -0,0 +1,190 @@
+/*
+ * This header file contains definitions for use when exchanging
+ * data with the user space
+ *
+ * The same file will also be installed for use by user space
+ * applications
+ *
+ * SO_BINDTOPVD and Co are defined in another uapi header file
+ * (asm-generic/socket.h)
+ */
+#ifndef _UAPI_LINUX_PVD_USER_H
+#define _UAPI_LINUX_PVD_USER_H
+
+#include <linux/in6.h>
+#ifndef __KERNEL__
+#include <net/if.h>
+#else
+#include <linux/if.h>
+#endif
+#include <linux/ipv6_route.h>
+
+/*
+ * MAXPVD must be a power of 2
+ */
+#define MAXPVDSHIFT 10 /* realistic upper bound */
+#define MAXPVD (1 << MAXPVDSHIFT)
+
+#ifndef PVDNAMSIZ
+#define PVDNAMSIZ 256
+#endif
+
+#ifndef FQDNSIZ
+#define FQDNSIZ 256
+#endif
+
+#ifndef MAXADDRPERPVD
+#define MAXADDRPERPVD 32
+#endif
+
+#ifndef MAXROUTESPERPVD
+#define MAXROUTESPERPVD 32
+#endif
+
+#ifndef MAXDNSSLPERPVD
+#define MAXDNSSLPERPVD 4
+#endif
+
+#ifndef MAXRDNSSPERPVD
+#define MAXRDNSSPERPVD 4
+#endif
+
+/*
+ * For SO_GETPVDATTRIBUTES (which returns the attributes for a pvd)
+ *
+ * The net_pvd_attribute structure below is a copy of the
+ * kernel space pvd structure, with kernel specific items
+ * removed
+ */
+struct net_pvd_route {
+ struct in6_addr dst;
+ struct in6_addr gateway;
+ char dev_name[IFNAMSIZ];
+};
+
+struct net_pvd_attribute {
+ char name[PVDNAMSIZ];
+ int index; /* unique number */
+
+ /*
+ * Attributes of the pvd
+ */
+ int sequence_number;
+ int h_flag;
+ int l_flag;
+ int a_flag; /* introduced in draft 01 */
+ int implicit_flag;
+ struct in6_addr lla;
+ char dev[IFNAMSIZ];
+
+ /*
+ * Induced attributes
+ */
+ int nroutes;
+ struct net_pvd_route routes[MAXROUTESPERPVD];
+ int naddresses;
+ struct in6_addr addresses[MAXADDRPERPVD];
+ int addr_prefix_len[MAXADDRPERPVD];
+
+ int ndnssl;
+ char dnssl[MAXDNSSLPERPVD][FQDNSIZ];
+
+ int nrdnss;
+ struct in6_addr rdnss[MAXRDNSSPERPVD];
+};
+
+struct pvd_attr {
+ char __user *pvdname; /* in */
+ struct net_pvd_attribute *pvdattr; /* out */
+};
+
+/*
+ * For SO_GETPVDLIST (returns the list of pvds)
+ */
+struct pvd_list {
+ int npvd; /* in/out */
+ char pvds[MAXPVD][PVDNAMSIZ];
+};
+
+/*
+ * For SO_BINDTOPVD (set and get)
+ */
+#define PVD_BIND_SCOPE_SOCKET 0
+#define PVD_BIND_SCOPE_THREAD 1
+#define PVD_BIND_SCOPE_PROCESS 2
+
+#define PVD_BIND_INHERIT 0
+#define PVD_BIND_NOPVD 1
+#define PVD_BIND_ONEPVD 2
+
+struct bind_to_pvd {
+ int scope; /* PVD_BIND_SCOPE_XXX */
+ int bindtype; /* PVD_BIND_INHERIT, ... */
+ char pvdname[PVDNAMSIZ];
+};
+
+/*
+ * For SO_CREATEPVD
+ */
+struct create_pvd {
+ char pvdname[PVDNAMSIZ];
+ int flag; /* mask : see below PVD_ATTR_XXX */
+ int sequence_number;
+ int h_flag;
+ int l_flag;
+ int deprecated;
+};
+
+#define PVD_ATTR_SEQNUMBER 0x01
+#define PVD_ATTR_HFLAG 0x02
+#define PVD_ATTR_LFLAG 0x04
+#define PVD_ATTR_DEPRECATED 0x08
+
+/*
+ * RTNETLINK related definitions
+ */
+/********************************************************************
+ * PvD description
+ * This is used to notify a change in a PvD
+ * Application may then query the attributes for the
+ * notified PvD using an alternate API
+ ****/
+
+struct pvdmsg {
+ char pvd_name[PVDNAMSIZ];
+ int pvd_state; /* NEW, UPDATE, DEL */
+};
+
+enum {
+ /*
+ * PVD_NEW and PVD_UPDATE will certainly be handled in the same way
+ * by application
+ */
+ PVD_NEW,
+ PVD_UPDATE,
+ PVD_DEL
+};
+
+struct rdnssmsg {
+ char pvd_name[PVDNAMSIZ];
+ struct in6_addr rdnss;
+ int rdnss_state; /* NEW, DEL */
+};
+
+enum {
+ RDNSS_NEW,
+ RDNSS_DEL
+};
+
+struct dnsslmsg {
+ char pvd_name[PVDNAMSIZ];
+ char dnssl[FQDNSIZ];
+ int dnssl_state; /* NEW, DEL */
+};
+
+enum {
+ DNSSL_NEW,
+ DNSSL_DEL
+};
+
+#endif /* _UAPI_LINUX_PVD_USER_H */
diff --git a/include/uapi/linux/rtnetlink.h b/include/uapi/linux/rtnetlink.h
index 843e29aa3cac..cc99e8b78cb9 100644
--- a/include/uapi/linux/rtnetlink.h
+++ b/include/uapi/linux/rtnetlink.h
@@ -150,6 +150,13 @@ enum {
RTM_NEWCACHEREPORT = 96,
#define RTM_NEWCACHEREPORT RTM_NEWCACHEREPORT
+ RTM_PVDSTATUS = 100,
+#define RTM_PVDSTATUS RTM_PVDSTATUS
+ RTM_RDNSS = 101,
+#define RTM_RDNSS RTM_RDNSS
+ RTM_DNSSL = 102,
+#define RTM_DNSSL RTM_DNSSL
+
__RTM_MAX,
#define RTM_MAX (((__RTM_MAX + 3) & ~3) - 1)
};
@@ -327,6 +334,7 @@ enum rtattr_type_t {
RTA_PAD,
RTA_UID,
RTA_TTL_PROPAGATE,
+ RTA_PVD,
__RTA_MAX
};
@@ -677,6 +685,8 @@ enum rtnetlink_groups {
#define RTNLGRP_IPV4_MROUTE_R RTNLGRP_IPV4_MROUTE_R
RTNLGRP_IPV6_MROUTE_R,
#define RTNLGRP_IPV6_MROUTE_R RTNLGRP_IPV6_MROUTE_R
+ RTNLGRP_PVD,
+#define RTNLGRP_PVD RTNLGRP_PVD
__RTNLGRP_MAX
};
#define RTNLGRP_MAX (__RTNLGRP_MAX - 1)
diff --git a/kernel/configs/kvm_guest.config b/kernel/configs/kvm_guest.config
index 8d9643767142..00b46f315c2e 100644
--- a/kernel/configs/kvm_guest.config
+++ b/kernel/configs/kvm_guest.config
@@ -1,6 +1,7 @@
CONFIG_NET=y
CONFIG_NET_CORE=y
CONFIG_NETDEVICES=y
+CONFIG_NETPVD=y
CONFIG_BLOCK=y
CONFIG_BLK_DEV=y
CONFIG_NETWORK_FILESYSTEMS=y
diff --git a/kernel/exit.c b/kernel/exit.c
index 995453d9fb55..b3c8217fd772 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -864,7 +864,14 @@ void __noreturn do_exit(long code)
exit_task_namespaces(tsk);
exit_task_work(tsk);
exit_thread(tsk);
-
+
+#ifdef CONFIG_NETPVD
+ if (tsk->bound_pvd != ((void *) 0) &&
+ tsk->bound_pvd != ((void *) -1)) {
+ kfree(tsk->bound_pvd);
+ tsk->bound_pvd = NULL;
+ }
+#endif
/*
* Flush inherited counters to the parent - before the parent
* gets woken up by child-exit notifications.
diff --git a/kernel/fork.c b/kernel/fork.c
index ef641b54e22b..0c9e0c826b76 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -551,6 +551,15 @@ static struct task_struct *dup_task_struct(struct task_struct *orig, int node)
if (err)
goto free_stack;
+#ifdef CONFIG_NETPVD
+ /*
+ * The new structure must inherit pvd from its parent (to avoid
+ * keeping a kstrdup() pointer in multiple structures)
+ */
+ tsk->bound_pvd = (void *) 0;
+#endif
+
+
#ifdef CONFIG_SECCOMP
/*
* We must handle setting up seccomp filters once we're under
diff --git a/net/6lowpan/core.c b/net/6lowpan/core.c
index 40d3d72beb53..f83f3c110068 100644
--- a/net/6lowpan/core.c
+++ b/net/6lowpan/core.c
@@ -135,7 +135,7 @@ static int lowpan_event(struct notifier_block *unused,
addrconf_ifid_802154_6lowpan(addr.s6_addr + 8, dev) == 0) {
__ipv6_addr_set_half(&addr.s6_addr32[0],
htonl(0xFE800000), 0);
- addrconf_add_linklocal(idev, &addr, 0);
+ addrconf_add_linklocal(idev, &addr, 0, NULL); /* FIXME : pvd == NULL ? */
}
break;
case NETDEV_DOWN:
diff --git a/net/6lowpan/ndisc.c b/net/6lowpan/ndisc.c
index 941df2fa4448..cf534cc81ad6 100644
--- a/net/6lowpan/ndisc.c
+++ b/net/6lowpan/ndisc.c
@@ -208,7 +208,8 @@ static void lowpan_ndisc_prefix_rcv_add_addr(struct net *net,
bool sllao, bool tokenized,
__u32 valid_lft,
u32 prefered_lft,
- bool dev_addr_generated)
+ bool dev_addr_generated,
+ void *pvd)
{
int err;
@@ -218,7 +219,8 @@ static void lowpan_ndisc_prefix_rcv_add_addr(struct net *net,
err = addrconf_prefix_rcv_add_addr(net, dev, pinfo, in6_dev,
addr, addr_type, addr_flags,
sllao, tokenized, valid_lft,
- prefered_lft);
+ prefered_lft,
+ pvd);
if (err)
ND_PRINTK(2, warn,
"RA: could not add a short address based address for prefix: %pI6c\n",
diff --git a/net/bridge/br_multicast.c b/net/bridge/br_multicast.c
index cb4729539b82..b160e967a617 100644
--- a/net/bridge/br_multicast.c
+++ b/net/bridge/br_multicast.c
@@ -501,6 +501,7 @@ static struct sk_buff *br_ip6_multicast_alloc_query(struct net_bridge *br,