@@ -67,6 +67,7 @@ static void usage(void)
6767 "IFADDR := PREFIX | ADDR peer PREFIX\n"
6868 " [ broadcast ADDR ] [ anycast ADDR ]\n"
6969 " [ label IFNAME ] [ scope SCOPE-ID ] [ metric METRIC ]\n"
70+ " [ proto IFAPROTO ]\n"
7071 "SCOPE-ID := [ host | link | global | NUMBER ]\n"
7172 "FLAG-LIST := [ FLAG-LIST ] FLAG\n"
7273 "FLAG := [ permanent | dynamic | secondary | primary |\n"
@@ -1508,6 +1509,9 @@ int print_addrinfo(struct nlmsghdr *n, void *arg)
15081509 return 0 ;
15091510 if ((filter .flags ^ ifa_flags ) & filter .flagmask )
15101511 return 0 ;
1512+ if (rta_tb [IFA_PROTO ])
1513+ if ((filter .proto ^ rta_getattr_u32 (rta_tb [IFA_PROTO ])) & filter .protomask )
1514+ return 0 ;
15111515
15121516 if (filter .family && filter .family != ifa -> ifa_family )
15131517 return 0 ;
@@ -1618,6 +1622,16 @@ int print_addrinfo(struct nlmsghdr *n, void *arg)
16181622
16191623 print_ifa_flags (fp , ifa , ifa_flags );
16201624
1625+ if (rta_tb [IFA_PROTO ]) {
1626+ __u8 prot = rta_getattr_u8 (rta_tb [IFA_PROTO ]);
1627+
1628+ if (prot != IFAPROT_UNSPEC )
1629+ print_string (PRINT_ANY ,
1630+ "protocol" ,
1631+ "proto %s " ,
1632+ rtnl_ifaprot_n2a (prot , b1 , sizeof (b1 )));
1633+ }
1634+
16211635 if (rta_tb [IFA_LABEL ])
16221636 print_string (PRINT_ANY ,
16231637 "label" ,
@@ -1872,6 +1886,10 @@ static void ipaddr_filter(struct nlmsg_chain *linfo, struct nlmsg_chain *ainfo)
18721886 if ((filter .flags ^ ifa_flags ) & filter .flagmask )
18731887 continue ;
18741888
1889+ if (tb [IFA_PROTO ])
1890+ if ((filter .proto ^ rta_getattr_u32 (tb [IFA_PROTO ])) & filter .protomask )
1891+ continue ;
1892+
18751893 if (ifa_label_match_rta (ifa -> ifa_index , tb [IFA_LABEL ]))
18761894 continue ;
18771895
@@ -2137,6 +2155,18 @@ static int ipaddr_list_flush_or_save(int argc, char **argv, int action)
21372155 } else {
21382156 filter .kind = * argv ;
21392157 }
2158+ } else if (strcmp (* argv , "proto" ) == 0 ) {
2159+ unsigned int proto = 0 ;
2160+
2161+ NEXT_ARG ();
2162+ filter .protomask = -1 ;
2163+ if (rtnl_ifaprot_a2n (& proto , * argv )) {
2164+ if (strcmp (* argv , "all" ) != 0 )
2165+ invarg ("invalid \"proto\"\n" , * argv );
2166+ proto = 0 ;
2167+ filter .protomask = 0 ;
2168+ }
2169+ filter .proto = proto ;
21402170 } else {
21412171 if (strcmp (* argv , "dev" ) == 0 )
21422172 NEXT_ARG ();
@@ -2434,6 +2464,13 @@ static int ipaddr_modify(int cmd, int flags, int argc, char **argv)
24342464 } else if (strcmp (* argv , "dev" ) == 0 ) {
24352465 NEXT_ARG ();
24362466 d = * argv ;
2467+ } else if (strcmp (* argv , "proto" ) == 0 ) {
2468+ __u32 prot ;
2469+
2470+ NEXT_ARG ();
2471+ if (rtnl_ifaprot_a2n (& prot , * argv ))
2472+ invarg ("Invalid \"protocol\" value\n" , * argv );
2473+ addattr8 (& req .n , sizeof (req ), IFA_PROTO , prot );
24372474 } else if (strcmp (* argv , "label" ) == 0 ) {
24382475 NEXT_ARG ();
24392476 l = * argv ;
0 commit comments