aboutsummaryrefslogtreecommitdiffstats
path: root/net/phonet/pn_netlink.c
diff options
context:
space:
mode:
authorJonathan Herman <hermanjl@cs.unc.edu>2013-01-17 16:15:55 -0500
committerJonathan Herman <hermanjl@cs.unc.edu>2013-01-17 16:15:55 -0500
commit8dea78da5cee153b8af9c07a2745f6c55057fe12 (patch)
treea8f4d49d63b1ecc92f2fddceba0655b2472c5bd9 /net/phonet/pn_netlink.c
parent406089d01562f1e2bf9f089fd7637009ebaad589 (diff)
Patched in Tegra support.
Diffstat (limited to 'net/phonet/pn_netlink.c')
-rw-r--r--net/phonet/pn_netlink.c32
1 files changed, 12 insertions, 20 deletions
diff --git a/net/phonet/pn_netlink.c b/net/phonet/pn_netlink.c
index 0193630d306..d61f6761777 100644
--- a/net/phonet/pn_netlink.c
+++ b/net/phonet/pn_netlink.c
@@ -5,8 +5,8 @@
5 * 5 *
6 * Copyright (C) 2008 Nokia Corporation. 6 * Copyright (C) 2008 Nokia Corporation.
7 * 7 *
8 * Authors: Sakari Ailus <sakari.ailus@nokia.com> 8 * Contact: Remi Denis-Courmont <remi.denis-courmont@nokia.com>
9 * Remi Denis-Courmont 9 * Original author: Sakari Ailus <sakari.ailus@nokia.com>
10 * 10 *
11 * This program is free software; you can redistribute it and/or 11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License 12 * modify it under the terms of the GNU General Public License
@@ -33,7 +33,7 @@
33/* Device address handling */ 33/* Device address handling */
34 34
35static int fill_addr(struct sk_buff *skb, struct net_device *dev, u8 addr, 35static int fill_addr(struct sk_buff *skb, struct net_device *dev, u8 addr,
36 u32 portid, u32 seq, int event); 36 u32 pid, u32 seq, int event);
37 37
38void phonet_address_notify(int event, struct net_device *dev, u8 addr) 38void phonet_address_notify(int event, struct net_device *dev, u8 addr)
39{ 39{
@@ -70,9 +70,6 @@ static int addr_doit(struct sk_buff *skb, struct nlmsghdr *nlh, void *attr)
70 int err; 70 int err;
71 u8 pnaddr; 71 u8 pnaddr;
72 72
73 if (!capable(CAP_NET_ADMIN))
74 return -EPERM;
75
76 if (!capable(CAP_SYS_ADMIN)) 73 if (!capable(CAP_SYS_ADMIN))
77 return -EPERM; 74 return -EPERM;
78 75
@@ -104,12 +101,12 @@ static int addr_doit(struct sk_buff *skb, struct nlmsghdr *nlh, void *attr)
104} 101}
105 102
106static int fill_addr(struct sk_buff *skb, struct net_device *dev, u8 addr, 103static int fill_addr(struct sk_buff *skb, struct net_device *dev, u8 addr,
107 u32 portid, u32 seq, int event) 104 u32 pid, u32 seq, int event)
108{ 105{
109 struct ifaddrmsg *ifm; 106 struct ifaddrmsg *ifm;
110 struct nlmsghdr *nlh; 107 struct nlmsghdr *nlh;
111 108
112 nlh = nlmsg_put(skb, portid, seq, event, sizeof(*ifm), 0); 109 nlh = nlmsg_put(skb, pid, seq, event, sizeof(*ifm), 0);
113 if (nlh == NULL) 110 if (nlh == NULL)
114 return -EMSGSIZE; 111 return -EMSGSIZE;
115 112
@@ -119,8 +116,7 @@ static int fill_addr(struct sk_buff *skb, struct net_device *dev, u8 addr,
119 ifm->ifa_flags = IFA_F_PERMANENT; 116 ifm->ifa_flags = IFA_F_PERMANENT;
120 ifm->ifa_scope = RT_SCOPE_LINK; 117 ifm->ifa_scope = RT_SCOPE_LINK;
121 ifm->ifa_index = dev->ifindex; 118 ifm->ifa_index = dev->ifindex;
122 if (nla_put_u8(skb, IFA_LOCAL, addr)) 119 NLA_PUT_U8(skb, IFA_LOCAL, addr);
123 goto nla_put_failure;
124 return nlmsg_end(skb, nlh); 120 return nlmsg_end(skb, nlh);
125 121
126nla_put_failure: 122nla_put_failure:
@@ -151,7 +147,7 @@ static int getaddr_dumpit(struct sk_buff *skb, struct netlink_callback *cb)
151 continue; 147 continue;
152 148
153 if (fill_addr(skb, pnd->netdev, addr << 2, 149 if (fill_addr(skb, pnd->netdev, addr << 2,
154 NETLINK_CB(cb->skb).portid, 150 NETLINK_CB(cb->skb).pid,
155 cb->nlh->nlmsg_seq, RTM_NEWADDR) < 0) 151 cb->nlh->nlmsg_seq, RTM_NEWADDR) < 0)
156 goto out; 152 goto out;
157 } 153 }
@@ -168,12 +164,12 @@ out:
168/* Routes handling */ 164/* Routes handling */
169 165
170static int fill_route(struct sk_buff *skb, struct net_device *dev, u8 dst, 166static int fill_route(struct sk_buff *skb, struct net_device *dev, u8 dst,
171 u32 portid, u32 seq, int event) 167 u32 pid, u32 seq, int event)
172{ 168{
173 struct rtmsg *rtm; 169 struct rtmsg *rtm;
174 struct nlmsghdr *nlh; 170 struct nlmsghdr *nlh;
175 171
176 nlh = nlmsg_put(skb, portid, seq, event, sizeof(*rtm), 0); 172 nlh = nlmsg_put(skb, pid, seq, event, sizeof(*rtm), 0);
177 if (nlh == NULL) 173 if (nlh == NULL)
178 return -EMSGSIZE; 174 return -EMSGSIZE;
179 175
@@ -187,9 +183,8 @@ static int fill_route(struct sk_buff *skb, struct net_device *dev, u8 dst,
187 rtm->rtm_scope = RT_SCOPE_UNIVERSE; 183 rtm->rtm_scope = RT_SCOPE_UNIVERSE;
188 rtm->rtm_type = RTN_UNICAST; 184 rtm->rtm_type = RTN_UNICAST;
189 rtm->rtm_flags = 0; 185 rtm->rtm_flags = 0;
190 if (nla_put_u8(skb, RTA_DST, dst) || 186 NLA_PUT_U8(skb, RTA_DST, dst);
191 nla_put_u32(skb, RTA_OIF, dev->ifindex)) 187 NLA_PUT_U32(skb, RTA_OIF, dev->ifindex);
192 goto nla_put_failure;
193 return nlmsg_end(skb, nlh); 188 return nlmsg_end(skb, nlh);
194 189
195nla_put_failure: 190nla_put_failure:
@@ -233,9 +228,6 @@ static int route_doit(struct sk_buff *skb, struct nlmsghdr *nlh, void *attr)
233 int err; 228 int err;
234 u8 dst; 229 u8 dst;
235 230
236 if (!capable(CAP_NET_ADMIN))
237 return -EPERM;
238
239 if (!capable(CAP_SYS_ADMIN)) 231 if (!capable(CAP_SYS_ADMIN))
240 return -EPERM; 232 return -EPERM;
241 233
@@ -282,7 +274,7 @@ static int route_dumpit(struct sk_buff *skb, struct netlink_callback *cb)
282 274
283 if (addr_idx++ < addr_start_idx) 275 if (addr_idx++ < addr_start_idx)
284 continue; 276 continue;
285 if (fill_route(skb, dev, addr << 2, NETLINK_CB(cb->skb).portid, 277 if (fill_route(skb, dev, addr << 2, NETLINK_CB(cb->skb).pid,
286 cb->nlh->nlmsg_seq, RTM_NEWROUTE)) 278 cb->nlh->nlmsg_seq, RTM_NEWROUTE))
287 goto out; 279 goto out;
288 } 280 }