Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0-or-later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  *  UDPLITE     An implementation of the UDP-Lite protocol (RFC 3828).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  *  Authors:    Gerrit Renker       <gerrit@erg.abdn.ac.uk>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  *  Changes:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  *  Fixes:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #define pr_fmt(fmt) "UDPLite: " fmt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <linux/export.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <linux/proc_fs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include "udp_impl.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) struct udp_table 	udplite_table __read_mostly;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) EXPORT_SYMBOL(udplite_table);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) static int udplite_rcv(struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 	return __udp4_lib_rcv(skb, &udplite_table, IPPROTO_UDPLITE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) static int udplite_err(struct sk_buff *skb, u32 info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 	return __udp4_lib_err(skb, info, &udplite_table);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) static const struct net_protocol udplite_protocol = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 	.handler	= udplite_rcv,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 	.err_handler	= udplite_err,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 	.no_policy	= 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 	.netns_ok	= 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) struct proto 	udplite_prot = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 	.name		   = "UDP-Lite",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 	.owner		   = THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 	.close		   = udp_lib_close,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 	.connect	   = ip4_datagram_connect,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 	.disconnect	   = udp_disconnect,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 	.ioctl		   = udp_ioctl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 	.init		   = udplite_sk_init,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	.destroy	   = udp_destroy_sock,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	.setsockopt	   = udp_setsockopt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 	.getsockopt	   = udp_getsockopt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 	.sendmsg	   = udp_sendmsg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 	.recvmsg	   = udp_recvmsg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 	.sendpage	   = udp_sendpage,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	.hash		   = udp_lib_hash,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	.unhash		   = udp_lib_unhash,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 	.rehash		   = udp_v4_rehash,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 	.get_port	   = udp_v4_get_port,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 	.memory_allocated  = &udp_memory_allocated,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	.sysctl_mem	   = sysctl_udp_mem,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	.obj_size	   = sizeof(struct udp_sock),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 	.h.udp_table	   = &udplite_table,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) EXPORT_SYMBOL(udplite_prot);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) static struct inet_protosw udplite4_protosw = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	.type		=  SOCK_DGRAM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	.protocol	=  IPPROTO_UDPLITE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	.prot		=  &udplite_prot,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	.ops		=  &inet_dgram_ops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 	.flags		=  INET_PROTOSW_PERMANENT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) #ifdef CONFIG_PROC_FS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) static struct udp_seq_afinfo udplite4_seq_afinfo = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 	.family		= AF_INET,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	.udp_table 	= &udplite_table,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) static int __net_init udplite4_proc_init_net(struct net *net)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	if (!proc_create_net_data("udplite", 0444, net->proc_net, &udp_seq_ops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 			sizeof(struct udp_iter_state), &udplite4_seq_afinfo))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) static void __net_exit udplite4_proc_exit_net(struct net *net)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	remove_proc_entry("udplite", net->proc_net);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) static struct pernet_operations udplite4_net_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	.init = udplite4_proc_init_net,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	.exit = udplite4_proc_exit_net,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) static __init int udplite4_proc_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	return register_pernet_subsys(&udplite4_net_ops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) static inline int udplite4_proc_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) void __init udplite4_register(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 	udp_table_init(&udplite_table, "UDP-Lite");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	if (proto_register(&udplite_prot, 1))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 		goto out_register_err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 	if (inet_add_protocol(&udplite_protocol, IPPROTO_UDPLITE) < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 		goto out_unregister_proto;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 	inet_register_protosw(&udplite4_protosw);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 	if (udplite4_proc_init())
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 		pr_err("%s: Cannot register /proc!\n", __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) out_unregister_proto:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 	proto_unregister(&udplite_prot);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) out_register_err:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 	pr_crit("%s: Cannot add UDP-Lite protocol\n", __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) }