Skip to content

Commit 673d57e

Browse files
hharrisondavem330
authored andcommitted
net: replace NIPQUAD() in net/ipv4/ net/ipv6/
Using NIPQUAD() with NIPQUAD_FMT, %d.%d.%d.%d or %u.%u.%u.%u can be replaced with %pI4 Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent cffee38 commit 673d57e

15 files changed

Lines changed: 78 additions & 103 deletions

File tree

‎net/ipv4/af_inet.c‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1070,11 +1070,8 @@ static int inet_sk_reselect_saddr(struct sock *sk)
10701070
return 0;
10711071

10721072
if (sysctl_ip_dynaddr > 1) {
1073-
printk(KERN_INFO "%s(): shifting inet->"
1074-
"saddr from " NIPQUAD_FMT " to " NIPQUAD_FMT "\n",
1075-
__func__,
1076-
NIPQUAD(old_saddr),
1077-
NIPQUAD(new_saddr));
1073+
printk(KERN_INFO "%s(): shifting inet->saddr from %pI4 to %pI4\n",
1074+
__func__, &old_saddr, &new_saddr);
10781075
}
10791076

10801077
inet->saddr = inet->rcv_saddr = new_saddr;

‎net/ipv4/arp.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1308,7 +1308,7 @@ static void arp_format_neigh_entry(struct seq_file *seq,
13081308
#if defined(CONFIG_AX25) || defined(CONFIG_AX25_MODULE)
13091309
}
13101310
#endif
1311-
sprintf(tbuf, NIPQUAD_FMT, NIPQUAD(*(u32*)n->primary_key));
1311+
sprintf(tbuf, "%pI4", n->primary_key);
13121312
seq_printf(seq, "%-16s 0x%-10x0x%-10x%s * %s\n",
13131313
tbuf, hatype, arp_state_to_flags(n), hbuffer, dev->name);
13141314
read_unlock(&n->lock);
@@ -1321,7 +1321,7 @@ static void arp_format_pneigh_entry(struct seq_file *seq,
13211321
int hatype = dev ? dev->type : 0;
13221322
char tbuf[16];
13231323

1324-
sprintf(tbuf, NIPQUAD_FMT, NIPQUAD(*(u32*)n->key));
1324+
sprintf(tbuf, "%pI4", n->key);
13251325
seq_printf(seq, "%-16s 0x%-10x0x%-10x%s * %s\n",
13261326
tbuf, hatype, ATF_PUBL | ATF_PERM, "00:00:00:00:00:00",
13271327
dev ? dev->name : "*");

‎net/ipv4/fib_trie.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2399,8 +2399,8 @@ static int fib_trie_seq_show(struct seq_file *seq, void *v)
23992399
__be32 prf = htonl(mask_pfx(tn->key, tn->pos));
24002400

24012401
seq_indent(seq, iter->depth-1);
2402-
seq_printf(seq, " +-- " NIPQUAD_FMT "/%d %d %d %d\n",
2403-
NIPQUAD(prf), tn->pos, tn->bits, tn->full_children,
2402+
seq_printf(seq, " +-- %pI4/%d %d %d %d\n",
2403+
&prf, tn->pos, tn->bits, tn->full_children,
24042404
tn->empty_children);
24052405

24062406
} else {
@@ -2410,7 +2410,7 @@ static int fib_trie_seq_show(struct seq_file *seq, void *v)
24102410
__be32 val = htonl(l->key);
24112411

24122412
seq_indent(seq, iter->depth);
2413-
seq_printf(seq, " |-- " NIPQUAD_FMT "\n", NIPQUAD(val));
2413+
seq_printf(seq, " |-- %pI4\n", &val);
24142414

24152415
hlist_for_each_entry_rcu(li, node, &l->list, hlist) {
24162416
struct fib_alias *fa;

‎net/ipv4/icmp.c‎

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -683,10 +683,8 @@ static void icmp_unreach(struct sk_buff *skb)
683683
break;
684684
case ICMP_FRAG_NEEDED:
685685
if (ipv4_config.no_pmtu_disc) {
686-
LIMIT_NETDEBUG(KERN_INFO "ICMP: " NIPQUAD_FMT ": "
687-
"fragmentation needed "
688-
"and DF set.\n",
689-
NIPQUAD(iph->daddr));
686+
LIMIT_NETDEBUG(KERN_INFO "ICMP: %pI4: fragmentation needed and DF set.\n",
687+
&iph->daddr);
690688
} else {
691689
info = ip_rt_frag_needed(net, iph,
692690
ntohs(icmph->un.frag.mtu),
@@ -696,9 +694,8 @@ static void icmp_unreach(struct sk_buff *skb)
696694
}
697695
break;
698696
case ICMP_SR_FAILED:
699-
LIMIT_NETDEBUG(KERN_INFO "ICMP: " NIPQUAD_FMT ": Source "
700-
"Route Failed.\n",
701-
NIPQUAD(iph->daddr));
697+
LIMIT_NETDEBUG(KERN_INFO "ICMP: %pI4: Source Route Failed.\n",
698+
&iph->daddr);
702699
break;
703700
default:
704701
break;
@@ -729,12 +726,12 @@ static void icmp_unreach(struct sk_buff *skb)
729726
if (!net->ipv4.sysctl_icmp_ignore_bogus_error_responses &&
730727
inet_addr_type(net, iph->daddr) == RTN_BROADCAST) {
731728
if (net_ratelimit())
732-
printk(KERN_WARNING NIPQUAD_FMT " sent an invalid ICMP "
729+
printk(KERN_WARNING "%pI4 sent an invalid ICMP "
733730
"type %u, code %u "
734-
"error to a broadcast: " NIPQUAD_FMT " on %s\n",
735-
NIPQUAD(ip_hdr(skb)->saddr),
731+
"error to a broadcast: %pI4 on %s\n",
732+
&ip_hdr(skb)->saddr,
736733
icmph->type, icmph->code,
737-
NIPQUAD(iph->daddr),
734+
&iph->daddr,
738735
skb->dev->name);
739736
goto out;
740737
}
@@ -952,9 +949,8 @@ static void icmp_address_reply(struct sk_buff *skb)
952949
break;
953950
}
954951
if (!ifa && net_ratelimit()) {
955-
printk(KERN_INFO "Wrong address mask " NIPQUAD_FMT " from "
956-
"%s/" NIPQUAD_FMT "\n",
957-
NIPQUAD(*mp), dev->name, NIPQUAD(rt->rt_src));
952+
printk(KERN_INFO "Wrong address mask %pI4 from %s/%pI4\n",
953+
mp, dev->name, &rt->rt_src);
958954
}
959955
}
960956
rcu_read_unlock();

‎net/ipv4/ip_fragment.c‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -559,9 +559,8 @@ static int ip_frag_reasm(struct ipq *qp, struct sk_buff *prev,
559559
goto out_fail;
560560
out_oversize:
561561
if (net_ratelimit())
562-
printk(KERN_INFO
563-
"Oversized IP packet from " NIPQUAD_FMT ".\n",
564-
NIPQUAD(qp->saddr));
562+
printk(KERN_INFO "Oversized IP packet from %pI4.\n",
563+
&qp->saddr);
565564
out_fail:
566565
IP_INC_STATS_BH(dev_net(dev), IPSTATS_MIB_REASMFAILS);
567566
return err;

‎net/ipv4/ip_input.c‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -294,10 +294,8 @@ static inline int ip_rcv_options(struct sk_buff *skb)
294294
if (!IN_DEV_SOURCE_ROUTE(in_dev)) {
295295
if (IN_DEV_LOG_MARTIANS(in_dev) &&
296296
net_ratelimit())
297-
printk(KERN_INFO "source route option "
298-
NIPQUAD_FMT " -> " NIPQUAD_FMT "\n",
299-
NIPQUAD(iph->saddr),
300-
NIPQUAD(iph->daddr));
297+
printk(KERN_INFO "source route option %pI4 -> %pI4\n",
298+
&iph->saddr, &iph->daddr);
301299
in_dev_put(in_dev);
302300
goto drop;
303301
}

‎net/ipv4/ipcomp.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ static void ipcomp4_err(struct sk_buff *skb, u32 info)
3939
spi, IPPROTO_COMP, AF_INET);
4040
if (!x)
4141
return;
42-
NETDEBUG(KERN_DEBUG "pmtu discovery on SA IPCOMP/%08x/" NIPQUAD_FMT "\n",
43-
spi, NIPQUAD(iph->daddr));
42+
NETDEBUG(KERN_DEBUG "pmtu discovery on SA IPCOMP/%08x/%pI4\n",
43+
spi, &iph->daddr);
4444
xfrm_state_put(x);
4545
}
4646

‎net/ipv4/ipconfig.c‎

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ static int __init ic_defaults(void)
374374
*/
375375

376376
if (!ic_host_name_set)
377-
sprintf(init_utsname()->nodename, NIPQUAD_FMT, NIPQUAD(ic_myaddr));
377+
sprintf(init_utsname()->nodename, "%pI4", &ic_myaddr);
378378

379379
if (root_server_addr == NONE)
380380
root_server_addr = ic_servaddr;
@@ -387,11 +387,11 @@ static int __init ic_defaults(void)
387387
else if (IN_CLASSC(ntohl(ic_myaddr)))
388388
ic_netmask = htonl(IN_CLASSC_NET);
389389
else {
390-
printk(KERN_ERR "IP-Config: Unable to guess netmask for address " NIPQUAD_FMT "\n",
391-
NIPQUAD(ic_myaddr));
390+
printk(KERN_ERR "IP-Config: Unable to guess netmask for address %pI4\n",
391+
&ic_myaddr);
392392
return -1;
393393
}
394-
printk("IP-Config: Guessing netmask " NIPQUAD_FMT "\n", NIPQUAD(ic_netmask));
394+
printk("IP-Config: Guessing netmask %pI4\n", &ic_netmask);
395395
}
396396

397397
return 0;
@@ -979,10 +979,8 @@ static int __init ic_bootp_recv(struct sk_buff *skb, struct net_device *dev, str
979979
ic_myaddr = b->your_ip;
980980
ic_servaddr = server_id;
981981
#ifdef IPCONFIG_DEBUG
982-
printk("DHCP: Offered address " NIPQUAD_FMT,
983-
NIPQUAD(ic_myaddr));
984-
printk(" by server " NIPQUAD_FMT "\n",
985-
NIPQUAD(ic_servaddr));
982+
printk("DHCP: Offered address %pI4 by server %pI4\n",
983+
&ic_myaddr, &ic_servaddr);
986984
#endif
987985
/* The DHCP indicated server address takes
988986
* precedence over the bootp header one if
@@ -1177,11 +1175,11 @@ static int __init ic_dynamic(void)
11771175
return -1;
11781176
}
11791177

1180-
printk("IP-Config: Got %s answer from " NIPQUAD_FMT ", ",
1178+
printk("IP-Config: Got %s answer from %pI4, ",
11811179
((ic_got_reply & IC_RARP) ? "RARP"
11821180
: (ic_proto_enabled & IC_USE_DHCP) ? "DHCP" : "BOOTP"),
1183-
NIPQUAD(ic_servaddr));
1184-
printk("my address is " NIPQUAD_FMT "\n", NIPQUAD(ic_myaddr));
1181+
&ic_servaddr);
1182+
printk("my address is %pI4\n", &ic_myaddr);
11851183

11861184
return 0;
11871185
}
@@ -1206,14 +1204,12 @@ static int pnp_seq_show(struct seq_file *seq, void *v)
12061204
"domain %s\n", ic_domain);
12071205
for (i = 0; i < CONF_NAMESERVERS_MAX; i++) {
12081206
if (ic_nameservers[i] != NONE)
1209-
seq_printf(seq,
1210-
"nameserver " NIPQUAD_FMT "\n",
1211-
NIPQUAD(ic_nameservers[i]));
1207+
seq_printf(seq, "nameserver %pI4\n",
1208+
&ic_nameservers[i]);
12121209
}
12131210
if (ic_servaddr != NONE)
1214-
seq_printf(seq,
1215-
"bootserver " NIPQUAD_FMT "\n",
1216-
NIPQUAD(ic_servaddr));
1211+
seq_printf(seq, "bootserver %pI4\n",
1212+
&ic_servaddr);
12171213
return 0;
12181214
}
12191215

@@ -1387,13 +1383,13 @@ static int __init ip_auto_config(void)
13871383
*/
13881384
printk("IP-Config: Complete:");
13891385
printk("\n device=%s", ic_dev->name);
1390-
printk(", addr=" NIPQUAD_FMT, NIPQUAD(ic_myaddr));
1391-
printk(", mask=" NIPQUAD_FMT, NIPQUAD(ic_netmask));
1392-
printk(", gw=" NIPQUAD_FMT, NIPQUAD(ic_gateway));
1386+
printk(", addr=%pI4", &ic_myaddr);
1387+
printk(", mask=%pI4", &ic_netmask);
1388+
printk(", gw=%pI4", &ic_gateway);
13931389
printk(",\n host=%s, domain=%s, nis-domain=%s",
13941390
utsname()->nodename, ic_domain, utsname()->domainname);
1395-
printk(",\n bootserver=" NIPQUAD_FMT, NIPQUAD(ic_servaddr));
1396-
printk(", rootserver=" NIPQUAD_FMT, NIPQUAD(root_server_addr));
1391+
printk(",\n bootserver=%pI4", &ic_servaddr);
1392+
printk(", rootserver=%pI4", &root_server_addr);
13971393
printk(", rootpath=%s", root_server_path);
13981394
printk("\n");
13991395
#endif /* !SILENT */

‎net/ipv4/route.c‎

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1214,10 +1214,9 @@ static int rt_intern_hash(unsigned hash, struct rtable *rt, struct rtable **rp)
12141214
#if RT_CACHE_DEBUG >= 2
12151215
if (rt->u.dst.rt_next) {
12161216
struct rtable *trt;
1217-
printk(KERN_DEBUG "rt_cache @%02x: " NIPQUAD_FMT, hash,
1218-
NIPQUAD(rt->rt_dst));
1217+
printk(KERN_DEBUG "rt_cache @%02x: %pI4", hash, &rt->rt_dst);
12191218
for (trt = rt->u.dst.rt_next; trt; trt = trt->u.dst.rt_next)
1220-
printk(" . " NIPQUAD_FMT, NIPQUAD(trt->rt_dst));
1219+
printk(" . %pI4", &trt->rt_dst);
12211220
printk("\n");
12221221
}
12231222
#endif
@@ -1444,11 +1443,10 @@ void ip_rt_redirect(__be32 old_gw, __be32 daddr, __be32 new_gw,
14441443
reject_redirect:
14451444
#ifdef CONFIG_IP_ROUTE_VERBOSE
14461445
if (IN_DEV_LOG_MARTIANS(in_dev) && net_ratelimit())
1447-
printk(KERN_INFO "Redirect from " NIPQUAD_FMT " on %s about "
1448-
NIPQUAD_FMT " ignored.\n"
1449-
" Advised path = " NIPQUAD_FMT " -> " NIPQUAD_FMT "\n",
1450-
NIPQUAD(old_gw), dev->name, NIPQUAD(new_gw),
1451-
NIPQUAD(saddr), NIPQUAD(daddr));
1446+
printk(KERN_INFO "Redirect from %pI4 on %s about %pI4 ignored.\n"
1447+
" Advised path = %pI4 -> %pI4\n",
1448+
&old_gw, dev->name, &new_gw,
1449+
&saddr, &daddr);
14521450
#endif
14531451
in_dev_put(in_dev);
14541452
}
@@ -1468,9 +1466,8 @@ static struct dst_entry *ipv4_negative_advice(struct dst_entry *dst)
14681466
rt->fl.oif,
14691467
rt_genid(dev_net(dst->dev)));
14701468
#if RT_CACHE_DEBUG >= 1
1471-
printk(KERN_DEBUG "ipv4_negative_advice: redirect to "
1472-
NIPQUAD_FMT "/%02x dropped\n",
1473-
NIPQUAD(rt->rt_dst), rt->fl.fl4_tos);
1469+
printk(KERN_DEBUG "ipv4_negative_advice: redirect to %pI4/%02x dropped\n",
1470+
&rt->rt_dst, rt->fl.fl4_tos);
14741471
#endif
14751472
rt_del(hash, rt);
14761473
ret = NULL;
@@ -1534,10 +1531,9 @@ void ip_rt_send_redirect(struct sk_buff *skb)
15341531
if (IN_DEV_LOG_MARTIANS(in_dev) &&
15351532
rt->u.dst.rate_tokens == ip_rt_redirect_number &&
15361533
net_ratelimit())
1537-
printk(KERN_WARNING "host " NIPQUAD_FMT "/if%d ignores "
1538-
"redirects for " NIPQUAD_FMT " to " NIPQUAD_FMT ".\n",
1539-
NIPQUAD(rt->rt_src), rt->rt_iif,
1540-
NIPQUAD(rt->rt_dst), NIPQUAD(rt->rt_gateway));
1534+
printk(KERN_WARNING "host %pI4/if%d ignores redirects for %pI4 to %pI4.\n",
1535+
&rt->rt_src, rt->rt_iif,
1536+
&rt->rt_dst, &rt->rt_gateway);
15411537
#endif
15421538
}
15431539
out:
@@ -1730,8 +1726,8 @@ static void ipv4_link_failure(struct sk_buff *skb)
17301726

17311727
static int ip_rt_bug(struct sk_buff *skb)
17321728
{
1733-
printk(KERN_DEBUG "ip_rt_bug: " NIPQUAD_FMT " -> " NIPQUAD_FMT ", %s\n",
1734-
NIPQUAD(ip_hdr(skb)->saddr), NIPQUAD(ip_hdr(skb)->daddr),
1729+
printk(KERN_DEBUG "ip_rt_bug: %pI4 -> %pI4, %s\n",
1730+
&ip_hdr(skb)->saddr, &ip_hdr(skb)->daddr,
17351731
skb->dev ? skb->dev->name : "?");
17361732
kfree_skb(skb);
17371733
return 0;
@@ -1908,9 +1904,8 @@ static void ip_handle_martian_source(struct net_device *dev,
19081904
* RFC1812 recommendation, if source is martian,
19091905
* the only hint is MAC header.
19101906
*/
1911-
printk(KERN_WARNING "martian source " NIPQUAD_FMT " from "
1912-
NIPQUAD_FMT", on dev %s\n",
1913-
NIPQUAD(daddr), NIPQUAD(saddr), dev->name);
1907+
printk(KERN_WARNING "martian source %pI4 from %pI4, on dev %s\n",
1908+
&daddr, &saddr, dev->name);
19141909
if (dev->hard_header_len && skb_mac_header_was_set(skb)) {
19151910
int i;
19161911
const unsigned char *p = skb_mac_header(skb);
@@ -2219,9 +2214,8 @@ out: return err;
22192214
RT_CACHE_STAT_INC(in_martian_dst);
22202215
#ifdef CONFIG_IP_ROUTE_VERBOSE
22212216
if (IN_DEV_LOG_MARTIANS(in_dev) && net_ratelimit())
2222-
printk(KERN_WARNING "martian destination " NIPQUAD_FMT " from "
2223-
NIPQUAD_FMT ", dev %s\n",
2224-
NIPQUAD(daddr), NIPQUAD(saddr), dev->name);
2217+
printk(KERN_WARNING "martian destination %pI4 from %pI4, dev %s\n",
2218+
&daddr, &saddr, dev->name);
22252219
#endif
22262220

22272221
e_hostunreach:

‎net/ipv4/tcp_input.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2336,9 +2336,9 @@ static void DBGUNDO(struct sock *sk, const char *msg)
23362336
struct inet_sock *inet = inet_sk(sk);
23372337

23382338
if (sk->sk_family == AF_INET) {
2339-
printk(KERN_DEBUG "Undo %s " NIPQUAD_FMT "/%u c%u l%u ss%u/%u p%u\n",
2339+
printk(KERN_DEBUG "Undo %s %pI4/%u c%u l%u ss%u/%u p%u\n",
23402340
msg,
2341-
NIPQUAD(inet->daddr), ntohs(inet->dport),
2341+
&inet->daddr, ntohs(inet->dport),
23422342
tp->snd_cwnd, tcp_left_out(tp),
23432343
tp->snd_ssthresh, tp->prior_ssthresh,
23442344
tp->packets_out);

0 commit comments

Comments
 (0)