aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/udp.c
diff options
context:
space:
mode:
authorDmitry Mishin <dim@openvz.org>2006-03-21 01:45:21 -0500
committerDavid S. Miller <davem@davemloft.net>2006-03-21 01:45:21 -0500
commit3fdadf7d27e3fbcf72930941884387d1f4936f04 (patch)
tree167072cf1e60b6b307610563614b435ff0caa52d /net/ipv4/udp.c
parentc750360938b403e6cc193d293cfbcb099dd6c60e (diff)
[NET]: {get|set}sockopt compatibility layer
This patch extends {get|set}sockopt compatibility layer in order to move protocol specific parts to their place and avoid huge universal net/compat.c file in the future. Signed-off-by: Dmitry Mishin <dim@openvz.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/udp.c')
-rw-r--r--net/ipv4/udp.c51
1 files changed, 43 insertions, 8 deletions
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index 00840474a449..0b0721bd45c6 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -1207,16 +1207,13 @@ static int udp_destroy_sock(struct sock *sk)
1207/* 1207/*
1208 * Socket option code for UDP 1208 * Socket option code for UDP
1209 */ 1209 */
1210static int udp_setsockopt(struct sock *sk, int level, int optname, 1210static int do_udp_setsockopt(struct sock *sk, int level, int optname,
1211 char __user *optval, int optlen) 1211 char __user *optval, int optlen)
1212{ 1212{
1213 struct udp_sock *up = udp_sk(sk); 1213 struct udp_sock *up = udp_sk(sk);
1214 int val; 1214 int val;
1215 int err = 0; 1215 int err = 0;
1216 1216
1217 if (level != SOL_UDP)
1218 return ip_setsockopt(sk, level, optname, optval, optlen);
1219
1220 if(optlen<sizeof(int)) 1217 if(optlen<sizeof(int))
1221 return -EINVAL; 1218 return -EINVAL;
1222 1219
@@ -1256,15 +1253,31 @@ static int udp_setsockopt(struct sock *sk, int level, int optname,
1256 return err; 1253 return err;
1257} 1254}
1258 1255
1259static int udp_getsockopt(struct sock *sk, int level, int optname, 1256static int udp_setsockopt(struct sock *sk, int level, int optname,
1257 char __user *optval, int optlen)
1258{
1259 if (level != SOL_UDP)
1260 return ip_setsockopt(sk, level, optname, optval, optlen);
1261 return do_udp_setsockopt(sk, level, optname, optval, optlen);
1262}
1263
1264#ifdef CONFIG_COMPAT
1265static int compat_udp_setsockopt(struct sock *sk, int level, int optname,
1266 char __user *optval, int optlen)
1267{
1268 if (level != SOL_UDP)
1269 return compat_ip_setsockopt(sk, level,
1270 optname, optval, optlen);
1271 return do_udp_setsockopt(sk, level, optname, optval, optlen);
1272}
1273#endif
1274
1275static int do_udp_getsockopt(struct sock *sk, int level, int optname,
1260 char __user *optval, int __user *optlen) 1276 char __user *optval, int __user *optlen)
1261{ 1277{
1262 struct udp_sock *up = udp_sk(sk); 1278 struct udp_sock *up = udp_sk(sk);
1263 int val, len; 1279 int val, len;
1264 1280
1265 if (level != SOL_UDP)
1266 return ip_getsockopt(sk, level, optname, optval, optlen);
1267
1268 if(get_user(len,optlen)) 1281 if(get_user(len,optlen))
1269 return -EFAULT; 1282 return -EFAULT;
1270 1283
@@ -1293,6 +1306,24 @@ static int udp_getsockopt(struct sock *sk, int level, int optname,
1293 return 0; 1306 return 0;
1294} 1307}
1295 1308
1309static int udp_getsockopt(struct sock *sk, int level, int optname,
1310 char __user *optval, int __user *optlen)
1311{
1312 if (level != SOL_UDP)
1313 return ip_getsockopt(sk, level, optname, optval, optlen);
1314 return do_udp_getsockopt(sk, level, optname, optval, optlen);
1315}
1316
1317#ifdef CONFIG_COMPAT
1318static int compat_udp_getsockopt(struct sock *sk, int level, int optname,
1319 char __user *optval, int __user *optlen)
1320{
1321 if (level != SOL_UDP)
1322 return compat_ip_getsockopt(sk, level,
1323 optname, optval, optlen);
1324 return do_udp_getsockopt(sk, level, optname, optval, optlen);
1325}
1326#endif
1296/** 1327/**
1297 * udp_poll - wait for a UDP event. 1328 * udp_poll - wait for a UDP event.
1298 * @file - file struct 1329 * @file - file struct
@@ -1350,6 +1381,10 @@ struct proto udp_prot = {
1350 .destroy = udp_destroy_sock, 1381 .destroy = udp_destroy_sock,
1351 .setsockopt = udp_setsockopt, 1382 .setsockopt = udp_setsockopt,
1352 .getsockopt = udp_getsockopt, 1383 .getsockopt = udp_getsockopt,
1384#ifdef CONFIG_COMPAT
1385 .compat_setsockopt = compat_udp_setsockopt,
1386 .compat_getsockopt = compat_udp_getsockopt,
1387#endif
1353 .sendmsg = udp_sendmsg, 1388 .sendmsg = udp_sendmsg,
1354 .recvmsg = udp_recvmsg, 1389 .recvmsg = udp_recvmsg,
1355 .sendpage = udp_sendpage, 1390 .sendpage = udp_sendpage,